Spring boot provides @ComponentScan
to find packages to be scanned.
I am building a library which has @RestControllers
inside with package com.mylib.controller
. There are other classes as well with stereotype annotations in different packages.
So, if some one is developing SpringBoot Application with com.myapp
base package.
He uses my library in his application. He need to mention @ComponentScan("com.mylib")
to discover stereotype components of library.
Is there any way to scan components without including library package in @ComponentScan
?
As spring-boot-starter-actuator expose its endpoints just with dependency, without defining @ComponentScan
. OR any default package which is scanned regardless of application base package.
@ComponentScan
in favor of@Configuration
files with@ConditionalOnXXXX
annotations. I have also created a blog post about creating a custom Spring Boot starter at tech.asimio.net/2017/06/29/… – Supervisory