繁体   English   中英

如何解决错误“无法排除以下类,因为它们不是自动配置类”?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM