簡體   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