While starting Spring Boot Application I am getting this error:
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. If I remove WebsecurityConfiguration.class
from exclude my application is not able to get properties from 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:
@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. I would remove the class from EnableAutoConfiguration and filter it with @ComponentScan and ExcludeAnnotationFilter instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.