我有自己的带有spring组件的jar文件。我正尝试在另一个项目中自动部署这个bean,但没有@Import或@ComponentScan我无法完成。有没有可能在没有额外注释的情况下构建jar并在另一个项目中使用它的bean?我需要的示例:
@Configuration
public class Config {
@Bean
public String init(@Autowired DistributorMessageSender distributorMessageSender) {
WebSocketMessage webSocketMessage = WebSocketMessage.builder().build();
distributorMessageSender.send(Channel.WEBSOCKET, webSocketMessage);
return new String();
}
}我想避免的是:
scanBasePackages = {"app", "distributor.client"}发布于 2021-08-06 09:15:19
我找到的解决方案是:构建我自己的自动配置类。它允许您在没有任何导入注释的情况下自动连接jar中的bean。我遵循的指南:https://docs.spring.io/spring-boot/docs/2.0.0.M3/reference/html/boot-features-developing-auto-configuration.html#boot-features-locating-auto-configuration-candidates
https://stackoverflow.com/questions/68652575
复制相似问题