我正在使用 maven 依赖项在另一个 spring boot 应用程序中将 spring boot 项目作为 jar 使用。仅当我启用来自微服务的自定义注释时,我才想对 jar 进行组件扫描。
@SpringBootApplication
//@ComponentScan({"com.jwt.security.*"}) To be removed by custom annotation
@MyCustomAnnotation //If I provide this annotation then the security configuration of the jar should be enabled.
public class MicroserviceApplication1 {
public static void main(String[] args) throws Exception {
SpringApplication.run(MicroserviceApplication1.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
请提出一些想法。