开发者

Using beans from another project

开发者 https://www.devze.com 2022-12-25 17:42 出处:网络
I\'m a novice on spring, I started to develop a new application with 2 modules, each one is a project, the first one is a java project, it contains the services beans declared in a servicescontext.xml

I'm a novice on spring, I started to develop a new application with 2 modules, each one is a project, the first one is a java project, it contains the services beans declared in a servicescontext.xml, the second projec开发者_如何学Pythont is a web application that uses the first project. I need to declare beans in the web application that use the services beans (the java project).


I guess this sort of depends on how you want to package the webapp. One solution that can work for you is to package the service-module as a jar file and then put it in the WEB-INF/lib of your webapp. You can then reference the other xml-file(s) from your webapp configuration. Take a look at this:

<import resource="servicescontext.xml"/>

Add "classpath" to reference the xml-file in the service-module jar file:

<import resource="classpath:servicescontext.xml"/>


You can use maven. Packge first project as jar and add its dependency in second project's pom.xml. You will be able to reference all the beans defined in first project.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号