Miciurash Miciurash - 1 month ago 16
Java Question

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

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 ?

Answer

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

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