2017-08-27 11 views
2

メインプロジェクトには2つのアーティファクトが含まれています。最初のパッケージにはパッケージ "com.parent.controller"が含まれています。 2番目は - "com.child.controller"です。コントローラ除外が機能しません

各パッケージには、それぞれコントローラ-ParentControllerChildContollerが含まれています。どちらも同じRequestMappingを持っています(たとえば、「/abc」など)。また、ParentControllerのフィルタを除外しました。しかし、いずれにしても私は例外があります: java.lang.IllegalStateException: Ambiguous mapping。それを修正するには?

@SpringBootConfiguration 
@EnableAutoConfiguration 
@EntityScan(basePackages = {"com.parent", "com.child"}) 
@ComponentScan(basePackages = {"com.parent", "com.child"}, excludeFilters = { 
    @ComponentScan.Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), 
    @ComponentScan.Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class), 
    @ComponentScan.Filter(type = FilterType.REGEX, pattern = "com\\.parent\\..*Controller"), 
    @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = ParentController.class) 
}) 

UPD 1。パッケージ階層:

- com 
    - parent 
    - controller 
     - ParentController 
    - service 
    - dao 
    - entity 
    - child 
    - controller 
     - ChildController 
    - service 
    - dao 
    - entity 
+0

同じマッピングを持つ2つのコントローラを使用する理由は何ですか? –

+0

@AbhijitSarkar、親アーティファクトは外部の変更不可能なライブラリです。そして、私はそれからいくつかのマッピングをオーバーライドしたいと思います。 –

答えて

2

com.parentルートパッケージをスキャンしないでください。 com.parent.entitiesのように、各サブパッケージを個別にスキャンします。その後除外は必要ありません。 それでも問題が解決しない場合は、特定の手順のために親と子のパッケージ階層を投稿してください。

+0

はい、動作します。ありがとう。 –

関連する問題