我所包括的主要项目2个假象。第一个包含包“com.parent.controller
”。第二个 - “com.child.controller
”。控制器排除不起作用
每个包包含一个位指示 - ParentController
和ChildContoller
,分别。它们都具有相同的RequestMapping(例如,只是“/abc
”)。我还包括ParentController
exlude过滤器。但在任何情况下,我有一个例外: 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
什么是有两个控制器具有相同映射的原因是什么? –
@AbhijitSarkar,父项目是外部不可修改的库。我想重写它的一些映射。 –