2 Commits

Author SHA1 Message Date
msksbr 93d3a26304 fix(config): set sensible default values for JSON date format and timezone
Change the default JSON date format from empty to `yyyy-MM-dd HH:mm:ss`
and the default timezone from `GMT` to `GMT+8`, matching the values
previously only configured in the dev profile.
2026-05-26 13:03:48 +08:00
msksbr 9521edaa43 feat(config): add CORS configuration for development environment
- configure global CORS policy allowing all origins, headers, and methods
- register CorsFilter bean for cross-origin request handling
- bump version to v0.1f
2026-05-24 20:37:41 +08:00
3 changed files with 34 additions and 3 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ plugins {
} }
group = "com.msksbr" group = "com.msksbr"
version = "v0.1" version = "v0.1f"
description = "bookMgr" description = "bookMgr"
java { java {
@@ -0,0 +1,31 @@
package com.msksbr.bookmgr.config
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.web.cors.CorsConfiguration
import org.springframework.web.cors.UrlBasedCorsConfigurationSource
import org.springframework.web.filter.CorsFilter
/*
* CORS 跨域配置
* 配置全局 CORS 策略,允许所有来源(origins)、请求头(headers)和 HTTP 方法
* 适用于前后端分离架构下的开发环境;生产环境建议按需收紧 allowedOrigins
*/
@Configuration
class CorsConfig {
/*
* 注册 CorsFilter Bean
* 拦截所有 / 路径并应用允许跨域的配置
*/
@Bean
fun corsFilter(): CorsFilter {
val config = CorsConfiguration()
config.addAllowedOrigin("*")
config.addAllowedHeader("*")
config.addAllowedMethod("*")
val source = UrlBasedCorsConfigurationSource()
source.registerCorsConfiguration("/**", config)
return CorsFilter(source)
}
}
+2 -2
View File
@@ -23,8 +23,8 @@ spring:
jackson: jackson:
default-property-inclusion: non_null # 序列化时忽略 null 字段 default-property-inclusion: non_null # 序列化时忽略 null 字段
property-naming-strategy: SNAKE_CASE # 实体驼峰 → JSON snake_case property-naming-strategy: SNAKE_CASE # 实体驼峰 → JSON snake_case
date-format: ${JSON_DATE_FORMAT:} # 日期格式,dev 配置中覆盖为 yyyy-MM-dd HH:mm:ss date-format: ${JSON_DATE_FORMAT:yyyy-MM-dd HH:mm:ss}
time-zone: ${JSON_TIME_ZONE:GMT} # 时区,dev 配置中覆盖为 GMT+8 time-zone: ${JSON_TIME_ZONE:GMT+8}
# ---- MyBatis-Plus ---- # ---- MyBatis-Plus ----
mybatis-plus: mybatis-plus: