File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
Register / Login


JavaRanch » Java Forums » Frameworks » Spring
Reply 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: 234
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: 1282

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
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
lookup method injection question
Should not use getBean() method ?
setBeanFactory of BeanFactorAware not getting invoked