Spring Boot ConflictingBeanDefinitionException: Annotation-specified bean name for @Controller class

后端 未结 6 1914
南旧
南旧 2021-02-18 13:50

I keep getting the ConflictingBeanDefinitionException error in my Spring boot application. I am not entirely sure as to how to address it, I have several @Con

6条回答
  •  醉话见心
    2021-02-18 14:44

    The solution, as I found out, is to disable double initialization by including a filter in the component scan. In my case:

    @EnableScheduling
    @EnableAspectJAutoProxy
    @EnableCaching
    @Configuration
    @ComponentScan(basePackages = { "org.kemri.wellcome.hie" }, 
        excludeFilters = {@Filter(value = Controller.class, type = FilterType.ANNOTATION)})
    @EnableAutoConfiguration
    @PropertySource("classpath:application.properties")
    public class Application extends SpringBootServletInitializer {
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    }
    

提交回复
热议问题