trigger component scan from a application for an included spring boot jar using extra annotations
<p>I need to publish a Spring boot based jar which should be consumed in other Spring/Spring boot based applications.
In my reuse jar I have a class(BusinessConfig) annotated with @Configuration and it gives out two beans. This class is in the base package of the reuse jar.</p>

<pre><code> @Configuration
public class BusinessConfig {
    @Bean(name = "BusinessRepoManager")
    public BusinessRepoManager businessRepoManager(){
       return BusinessRepoManager.getInstance();
    }

    @Autowired
    @Bean(name = "CustomerManager")
    @Scope("request")
    public CustomerManager customerManager(BusinessRepoManager busrepoManager){
        return CustomerManager.getInstance();
    }

}
</code></pre>

<p>In the second application, I have added the dependency and in the application class I have the statement </p>

<pre><code>@ComponentScan(basePackageClasses = {BusinessConfig.class})
</code></pre>

<p>to inform Spring context to look for beans provided in BusinessConfig class as well.</p>

<p>This works well, as I could see the beans getting created.</p>

<p>Is there any possibility to simplify this, should all consuming applications know the class name in which my configuration exists/package name.
I tried creating a custom annotation in the jar project and used that in the consuming application. </p>

<pre><code>@ComponentScan(basePackageClasses = {BusinessConfig.class})
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Component
public @interface EnableDemoBusiness {

}
</code></pre>

<p>Then in my consuming application I just added </p>

<pre><code> @EnableDemoBusiness
    @SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}
</code></pre>

<p>Is there any way to get this work ?</p>

<p>Thanks in advance !</p>