开发者

How to load a spring beans which are in jar file in projects lib folder

How can I load a spring beans which are in jar file say for eg. sample.jar with all the beans declared in that jar with sample-applicationContext.xml?

Now I am using some of the beans from this jar in my project so when I deploy my ear file this sample.jar is in lib folder. Now when I deploy this project to server(jboss -5) it is not injecting the bean i have referenced in my main project.

we dont have any web app in this ear so the way we are loading beans are using ClassPathXmlApplicationContext. Can somebo开发者_JAVA百科dy gave me an example of how to load those beans from sample.jar(lib folder) first and then load those are in the project, so when spring creates beans in the main project it will have beans from sample.jar and would inject them.

Thanks


Beans are looked-up on the classpath, so if they are annotated and your have the proper component scan, they should be discovered.

If they are not annotated, but only listed in the sample-applicationContext.xml, then you can <import resource="classpath:sample-applicationContext.xml" />

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜