Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to creaate ApplicationContext for a jar?

 
peter tong
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic