diff --git a/forgeboot-webmvc/forgeboot-webmvc-version-starter/src/main/kotlin/com/gewuyou/forgeboot/webmvc/version/config/VersionAutoConfiguration.kt b/forgeboot-webmvc/forgeboot-webmvc-version-starter/src/main/kotlin/com/gewuyou/forgeboot/webmvc/version/config/VersionAutoConfiguration.kt index 9c5d678..545684d 100644 --- a/forgeboot-webmvc/forgeboot-webmvc-version-starter/src/main/kotlin/com/gewuyou/forgeboot/webmvc/version/config/VersionAutoConfiguration.kt +++ b/forgeboot-webmvc/forgeboot-webmvc-version-starter/src/main/kotlin/com/gewuyou/forgeboot/webmvc/version/config/VersionAutoConfiguration.kt @@ -3,6 +3,7 @@ package com.gewuyou.forgeboot.webmvc.version.config import com.gewuyou.forgeboot.core.extension.log import com.gewuyou.forgeboot.webmvc.version.config.entities.VersionProperties import com.gewuyou.forgeboot.webmvc.version.mapping.ApiVersionRequestMappingHandlerMapping +import jakarta.annotation.PostConstruct import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -20,6 +21,7 @@ open class VersionAutoConfiguration( private val versionProperties: VersionProperties, private val corsConfigurationSource: CorsConfigurationSource ) { + private lateinit var mapping: ApiVersionRequestMappingHandlerMapping /** * 创建并配置一个 ApiVersionRequestMappingHandlerMapping 实例 * @@ -34,7 +36,10 @@ open class VersionAutoConfiguration( log.info("创建 API 版本请求映射处理程序映射") return ApiVersionRequestMappingHandlerMapping(versionProperties).also { it.order = Int.MIN_VALUE - it.corsConfigurationSource = corsConfigurationSource } } + @PostConstruct + fun injectCors() { + mapping.corsConfigurationSource = corsConfigurationSource + } } \ No newline at end of file