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

java, spring, spring-boot, spring-mvc

Solution

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

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

Problem

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 is not aware of the components in the jar. How to make Spring's @ComponentScan search components in included JARs ?

Original source