Spring boot provides @ComponentScan to find packages to be scanned.
I am building a library which has @RestControllers
inside with package com
Spring boot starter are special artifacts designed by Spring and used by Spring.
You can check that in the source code that contains mainly a
spring.provides
file :
provides: spring-boot-actuator,micrometer-core
I don't know the exact way to process in the same way as Spring Boot Starter but as probably acceptable workaround, you could define in your jar a @Configuration
class that specifies @ComponentScan("com.mylib")
.
@Configuration
@ComponentScan("com.mylib")
public class MyLibConfig {
//...
}
In this way, clients of the jar need "only" to import the @Configuration
class :
@Import(MyLibConfig.class)
@Configuration
public class ClientConfig{
//...
}