Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

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 {

}
like image 264
paras mehta Avatar asked Jul 15 '20 08:07

paras mehta


1 Answers

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 {
like image 100
Konstantin Grigorov Avatar answered Nov 08 '22 12:11

Konstantin Grigorov