You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SpringBoot升级至3.1.1后,AuthenticationProperties类弃用求替代方案

问题解答

com.westernacher.xna.template.boot.AuthenticationProperties是Westernacher内部XNA模板的自定义类,并非Spring Boot官方提供的类。在Spring Boot 3.1.1(适配Spring Security 6.x)的升级场景下,该类被弃用的替代方案如下:

  • 优先查看项目依赖的Westernacher XNA模板新版本:官方通常会在升级后的模板中提供替代类,可能会调整类名或包路径,比如迁移到更贴合Spring Security 6规范的SecurityProperties类,或是在新包路径下保留调整后的AuthenticationProperties。
  • 如果无法找到内部替代类,可基于Spring Boot 3.x的规范重构:
    1. 利用Spring Boot官方的org.springframework.boot.autoconfigure.security.SecurityProperties作为基础配置类;
    2. 若需要自定义认证相关属性,可通过@ConfigurationProperties注解创建自己的配置绑定类,示例:
      @ConfigurationProperties(prefix = "authentication")
      public class CustomAuthenticationProperties {
          // 原AuthenticationProperties中的属性定义
          private String loginUrl;
          // getter、setter方法
      }
      
    3. 在配置类中启用该自定义配置:
      @Configuration
      @EnableConfigurationProperties(CustomAuthenticationProperties.class)
      public class SecurityConfig {
          // 注入CustomAuthenticationProperties并使用
      }
      

内容的提问来源于stack exchange,提问作者Akshay Sarambale

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 15:32:03