在我的 Spring Boot 项目中,我对 SecurityFilterChain 进行了以下定义:
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http
// public routes
.authorizeHttpRequests()
.requestMatchers("/", "/favicon.ico", "/v3/api-docs*")
.permitAll()
.and()
// enable security for the log-view
.authorizeHttpRequests()
.requestMatchers("/log")
.hasAnyRole(ROLE_LOGVIEWER)
.and()
// enable security for the health check
.authorizeHttpRequests()
.requestMatchers("/manage/health")
.hasAnyRole(ROLE_HEALTH)
.and()
// enable basic-auth and ROLE_USER for all other routes
.authorizeHttpRequests()
.anyRequest()
.hasAnyRole(ROLE_USER)
.and()
.httpBasic();
return http.build();
}
Run Code Online (Sandbox Code Playgroud)
它在多个模型测试中进行了测试,并在生产环境中按预期运行。
但是从 spring-boot 3.0.8 迁移到 3.0.9 后,出现以下错误:
Factory method 'filterChain' threw exception with message: This method cannot decide whether …Run Code Online (Sandbox Code Playgroud) 我需要在 Spring Boot API 中支持 swagger 2 & 3。
我已经使用 docket 对象创建了 swagger 2 并且对于 swagger 3 刚刚添加了 maven 依赖项springdoc-openapi-ui。能够检查 swagger 2 和 3 文档。
如何仅禁用/启用 swagger 3 或 swagger 2?我的意思是如何禁用 swagger 3 配置?
我没有 swagger 3 配置类来启用/禁用使用@profile. 只需添加springdoc-openapi-uimaven 依赖 swagger 3 即可。