Класс PersonController находится внутри модуля external (этот модуль также имеет зависимость) – аннотации @RestControllerВ моем модуле Application я создаю экземпляры bean-компонентов как таковые и ожидаю, что PersonController из пользовательской зависимости не будет включен. Как видите, компонентComponentScan необходим для других классов, которые я использую из пользовательской зависимости
Код: Выделить всё
@Configuration
@ComponentScan(
basePackages = "xl.person",
excludeFilters={
@ComponentScan.Filter(
type = FilterType.ASSIGNABLE_TYPE,
value = { xl.person.controller.PersonController.class }
)
}
)
public class PersonConfiguration {
@Bean
@Primary
PersonController personController(
PersonService service, //from dependency
PersonSecondService serviceTwo //not from dependency
) {
return new PersonController(service, serviceTwo);
}
}
Код: Выделить всё
@SpringBootApplication(
scanBasePackages = "xl.app"
exclude = { PersonController.class }
)
Код: Выделить всё
//Annotation-specified bean name 'personController' for bean class [xl.person.controller.PersonController] conflicts with existing, non-compatible bean definition of same name and class [xl.app.external.PersonController]
Подробнее здесь: https://stackoverflow.com/questions/793 ... dependency
Мобильная версия