This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 1648
    
    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]
 
jQuery in Action, 2nd edition
 
subject: How to creaate ApplicationContext for a jar?
 
Similar Threads
Declarative Usage of Application Contexts
setBeanFactory of BeanFactorAware not getting invoked
Should not use getBean() method ?
Why am I getting NoSuchBeanDefinition Exception? I am new to Spring!
lookup method injection question