aspose file tools*
The moose likes Spring and the fly likes How to creaate ApplicationContext for a jar? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to creaate ApplicationContext for a jar?" Watch "How to creaate ApplicationContext for a jar?" New topic
Author

How to creaate ApplicationContext for a jar?

peter tong
Ranch Hand

Joined: Mar 15, 2008
Posts: 240
I think ApplicationContext should only create once and then use it to getBean, again, I see many example in Web which create applicationcontext in the main method


But for my case, it is packed as a jar and no main method, it is just called by a webapp and not a standalone application, then where should I create ApplicationContext for this jar?
I think it is not good to create applicationcontext each time I need getBean, right?
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1669
    
    7

Spring will look in jars too as long as its in the classpath. Use the ContextLoader in the web.xml to load it from the jar in addition to any contexts in the web-app.



Or to avoid time scanning declare them explicitly




[How To Ask Questions][Read before you PM me]
 
wood burning stoves
 
subject: How to creaate ApplicationContext for a jar?