0
目前,我指定我的春節開機自動配置不包括下列方式:Spring Boot:如何重新使用@EnableAutoConfiguration?
@EnableAutoConfiguration(exclude = { ... })
@ComponentScan("my.company")
class Application {
static void main(String[] args) {
...
}
}
由於Spring啓動將用於全公司,我們願意提供像MyCompanyDefaultConfiguration
一些默認的配置類的一些自動如果需要,配置會排除並僅指定每個應用程序的添加排除項。
事情是這樣的:
@Import(MyCompanyDefaultConfiguration.class)
@EnableAutoConfiguration(exclude = { /* application specific excludes */ })
class Application {
static void main(String[] args) {
...
}
}
@EnableAutoConfiguration(exclude = { /* company-wide excludes */ })
@ComponentScan("my.company")
class MyCompanyDefaultConfiguration {
...
}
我讀的地方,這是行不通的,因爲應該是每個應用程序只有一個@EnableAutoConfiguration
註釋,因爲春天開機將只考慮第一個找到的人。在這種情況下,應用程序類中的一個。
考慮到這個限制,以可重用的方式組織此配置的解決方案是什麼?