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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 1632
    
    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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to creaate ApplicationContext for a jar?
 
Similar Threads
Why am I getting NoSuchBeanDefinition Exception? I am new to Spring!
Declarative Usage of Application Contexts
setBeanFactory of BeanFactorAware not getting invoked
Should not use getBean() method ?
lookup method injection question