升级spring-boot-actuator-autoconfigure后应用启动失败求助
问题原因
Spring Boot 2.7.11版本中,org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration已不再是自动配置类(该类的职责在版本迭代中被重构或由其他机制接管),因此在@SpringBootApplication的exclude参数中指定该类会触发IllegalStateException错误。
解决方案
移除无效的排除类
修改Application.java中的@SpringBootApplication注解,删除ManagementWebSecurityAutoConfiguration.class:@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })通过配置属性替代类排除(如果需要禁用管理端点安全)
若你原本排除该类是为了关闭管理端点的安全校验,在2.7.x版本中推荐使用配置属性实现:
在application.properties中添加:# 关闭管理端点的安全校验 management.security.enabled=false # 若需要完全禁用Spring Security(根据实际需求选择) # spring.security.enabled=false若需要更细粒度的端点权限控制,可根据Spring Boot 2.7.x的配置规范调整相关属性。
内容的提问来源于stack exchange,提问作者Ciby
相关产品推荐
相关产品推荐

