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

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


Give it the appropriate package name to scan in the JAR.

@ComponentScan(basePackages = {"com.example.from.jar"})


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.