简体   繁体   English

Spring 引导多模块项目和bean创建顺序

[英]Spring Boot multi module project and bean creation order

I have a main module named core and other modules that defines Spring beans of type Job .我有一个名为core的主模块和其他模块,它们定义了Job类型的 Spring bean。

I'd like to have a List<Job> in my main module.我想在我的主模块中有一个List<Job>

The problem is that the creation of the @Service class that contains the @Autowired List<Jobs> is happening prior to the creation of the Jobs in the other modules (which are a maven dependency in core ).问题是包含@Autowired List<Jobs>@Service class 的创建是在其他模块中创建作业之前发生的(这是core中的 maven 依赖项)。

How can I direct Spring to gather all Jobs into a list in the main module?如何指示 Spring 将所有作业收集到主模块中的列表中?

I tried to use @Order but it doesn't seem to make any affect.我尝试使用@Order ,但似乎没有任何影响。

Try creating Job bean under configuration file.尝试在配置文件下创建 Job bean。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM