[英]How to resolve error “The following classes could not be excluded because they are not auto-configuration classes”?
While starting Spring Boot Application I am getting this error:在启动 Spring 启动应用程序时,我收到此错误:
The following classes could not be excluded because they are not auto-configuration classes:
- org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration
This is how my application looks like.这就是我的应用程序的样子。 I have excluded
WebsecurityConfiguration.class
from EnablEAutoConfiguration
but I keep on getting the above error.我已经从
EnablEAutoConfiguration
WebsecurityConfiguration.class
我不断收到上述错误。 If I remove WebsecurityConfiguration.class
from exclude my application is not able to get properties from application.yaml
.如果我从排除中删除
WebsecurityConfiguration.class
我的应用程序无法从application.yaml
获取属性。 Can you please help me in resolving this issue?你能帮我解决这个问题吗?
@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 {
}
In the entry point for your SpringBoot app, use the following:在 SpringBoot 应用程序的入口点中,使用以下命令:
@SpringBootApplication
@ComponentScan(excludeFilters={@ComponentScan.Filter(type= FilterType.ASSIGNABLE_TYPE, value=<classThatYouWantToExclued>.class)})
public class TestApplication {
The error is telling you that WebSecurityConfiguration
is not an auto-configuration class, but you are excluding it in the @Enable AutoConfiguration section.该错误告诉您
WebSecurityConfiguration
不是自动配置 class,但您在 @Enable AutoConfiguration部分中将其排除在外。 I would remove the class from EnableAutoConfiguration and filter it with @ComponentScan and ExcludeAnnotationFilter instead.我会从 EnableAutoConfiguration 中删除 class 并使用 @ComponentScan 和 ExcludeAnnotationFilter 过滤它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.