How to make Spring's @ComponentScan search components in included JARs

前端 未结 2 1365
梦如初夏
梦如初夏 2020-12-05 11:27

I made a jar with Spring components to include in multiple projects (core.jar).

I created a new Spring project, have @ComponentScan to the correct package, but it i

2条回答
  •  执念已碎
    2020-12-05 12:02

    I had a similar issue with Spring boot and @ComponentScan and this document helped me solving the issue: http://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-structuring-your-code.html.

    The point was that my @SpringBootApplication class was in the root package of one of basePackages of @ComponentScan. After I moved it to a subpackage, Spring was able to recognize all @ComponentScans.

提交回复
热议问题