简体   繁体   中英

Application Context Null in different project and unable to access beans

I have a project (project1) which has beans declared using @component and using application context I am able to access the beans. Now there is another project(spring boot project- project2) in which I am using this project1 as dependency. In that I am trying to access beans of project1 using autowired annotation but it is throwing null pointer exception both for beans and Application context. How can I access application context of project1 which has access to those beans in my project so that I can use both autowired application context and access beans of project1 in project2 Any idea what is wrong and why autowiring not working.

Thanks

You need to import configuration from project 1 into project 2. Something like below

@Configuration
@EnableBatchProcessing
@ComponentScan({"abc.","com.abc"})
@Import({Project1Config.class})
public class Project2Configuration {
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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