[英]How to resolve error “The following classes could not be excluded because they are not auto-configuration classes”?
在启动 Spring 启动应用程序时,我收到此错误:
The following classes could not be excluded because they are not auto-configuration classes:
- org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration
这就是我的应用程序的样子。 我已经从EnablEAutoConfiguration
WebsecurityConfiguration.class
我不断收到上述错误。 如果我从排除中删除WebsecurityConfiguration.class
我的应用程序无法从application.yaml
获取属性。 你能帮我解决这个问题吗?
@Configuration
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, SecurityAutoConfiguration.class,
ManagementWebSecurityAutoConfiguration.class, WebSecurityConfiguration.class
})
// @ComponentScan("com.infy.ceh.management")
@ComponentScan(basePackages = "com.infy.ceh.management", excludeFilters = @Filter(type = FilterType.CUSTOM, value = {
ExcludeAnnotationFilter.class })
)
public class AgentApplication {
}
在 SpringBoot 应用程序的入口点中,使用以下命令:
@SpringBootApplication
@ComponentScan(excludeFilters={@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, value=<classThatYouWantToExclued>.class)})
public class TestApplication {
该错误告诉您WebSecurityConfiguration
不是自动配置 class,但您在 @Enable AutoConfiguration部分中将其排除在外。 我会从 EnableAutoConfiguration 中删除 class 并使用 @ComponentScan 和 ExcludeAnnotationFilter 过滤它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.