Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 93d3a26304 | |||
| 9521edaa43 |
+1
-1
@@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.msksbr"
|
||||
version = "v0.1"
|
||||
version = "v0.1f"
|
||||
description = "bookMgr"
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -23,8 +23,8 @@ spring:
|
||||
jackson:
|
||||
default-property-inclusion: non_null # 序列化时忽略 null 字段
|
||||
property-naming-strategy: SNAKE_CASE # 实体驼峰 → JSON snake_case
|
||||
date-format: ${JSON_DATE_FORMAT:} # 日期格式,dev 配置中覆盖为 yyyy-MM-dd HH:mm:ss
|
||||
time-zone: ${JSON_TIME_ZONE:GMT} # 时区,dev 配置中覆盖为 GMT+8
|
||||
date-format: ${JSON_DATE_FORMAT:yyyy-MM-dd HH:mm:ss}
|
||||
time-zone: ${JSON_TIME_ZONE:GMT+8}
|
||||
|
||||
# ---- MyBatis-Plus ----
|
||||
mybatis-plus:
|
||||
|
||||
Reference in New Issue
Block a user