Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initialize Spring beans packaged inside a jar file

In a web-app, we define the context config location for spring to initialize all the beans like this

 <!-- Spring Application Configuration -->
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/spring/ctx-*.xml</param-value>
 </context-param>
 <listener>
  <description>Spring Context Listener</description>
  <display-name>SpringContextListener</display-name>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>

I am trying to find out, if it is possible to do that inside a jar file (containing all the spring beans) where I donot have a web.xml?

like image 372
subh Avatar asked Oct 26 '22 19:10

subh


1 Answers

you can use the prefix 'classpath:'

classpath:ctx-*.xml

see http://static.springsource.org/spring/docs/2.5.6/reference/resources.html#resources-app-ctx

like image 107
Stefan De Boey Avatar answered Nov 02 '22 11:11

Stefan De Boey