简体   繁体   English

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

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

相关问题 在Swagger自动配置过程中会扫描哪些类? - Which classes are scanned during the Swagger auto-configuration process? 找不到以下类错误(最新版本) - The Following Classes Could not Be Found Error (latest version) 如何通过自己的自动配置使用WebMvcConfigurationSupport - How to use WebMvcConfigurationSupport from own auto-configuration 如何在测试中启用Spring的自动配置报告? - How to enable Spring's auto-configuration report in tests? 如何使用 quarkus 在父 maven 项目中创建自定义自动配置 - how create a custom Auto-Configuration in parent maven project with quarkus 如何避免由于 Kotlin 构建错误而重新启动 Android Studio:无法解析以下类的超类型 - How do I avoid restarting Android Studio because of a Kotlin build error: Supertypes of the following classes cannot be resolved Android-无法实例化以下类 - Android - The following classes could not be instantiated FloatinActionButton:无法实例化以下类 - FloatinActionButton: the following classes could not be instantiated 如何修复 Java 中的“找不到以下类:-android.support.v7.widget.Toolbar”错误 - How to fix 'The following classes could not be found: - android.support.v7.widget.Toolbar' error in Java Spring Boot自动配置顺序 - Spring Boot auto-configuration order
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM