小编Thi*_*arz的帖子

Spring Boot 从 3.0.8 迁移到 3.0.9 后,SecurityFilterChain 无法实例化

在我的 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)

java spring-security spring-boot

9
推荐指数
2
解决办法
4513
查看次数

如何在 Spring Boot 中禁用 swagger 3 配置

我需要在 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 即可。

swagger swagger-ui swagger-2.0 swagger-3.0

3
推荐指数
1
解决办法
1506
查看次数