2017-05-30 17 views
0

は現在、私は次のように私の春ブーツ自動設定除外を指定しています:春ブーツは、会社全体で使用されるようにスプリングブート:@EnableAutoConfigurationはどのように再利用できますか?

@EnableAutoConfiguration(exclude = { ... }) 
@ComponentScan("my.company") 
class Application { 
    static void main(String[] args) { 
     ... 
    } 
} 

、我々はいくつかの自動でMyCompanyDefaultConfigurationのようないくつかのデフォルト設定クラスを提供したいと思います必要に応じてアプリケーションごとに追加除外を指定するだけです。

このような何か:私は春ブーツだけ最初に見つかったものを検討するため、アプリケーションごとに1つだけの@EnableAutoConfiguration注釈がなければならないとして、これは、動作しないことをどこかで読んだ

@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 { 
    ... 
} 

。この場合は、Applicationクラスのものです。

この制限を念頭に置いて、再構成可能な方法でこの構成を構成するソリューションは何ですか。

答えて

0

@EnableAutoConfigurationのような注釈付き注釈は、注釈付き注釈です。

@EnableAutoConfiguration(exclude = { /* application specific excludes */ }) 
public @interface MyCompanyEnableAutoConfiguration { 
} 

それを使用します
関連する問題