Loading Spring Context Dynamically at Run-time in a Web Application
I'm converting a standard Java Application that uses Spring Framework into a Web App. This application loads new Spring Context based on run-time parameters, that was done us开发者_如何学运维ing ClassPathXmlApplicationContext/FileSystemXmlApplicationContext
.
So my question is how to do the same in a Web Application given that I already configured my web.xml and added Spring Listeners as below:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Another Problem, my deployment environment is on Tomcat 5.5 where I'm not able to see any logging during spring context loading to know what's wrong.
If you actually mean to load a configurable context on start up of your weblication you could configure your web.xml with a property placeholder for the context name.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:${my_context_file}</param-value>
</context-param>
To turn on logging you may need to set it in your log4j.properties file, like so: log4j.logger.org.springframework=DEBUG
You also have to ensure that you are logging to the CONSOLE and not some other stream. If you are then log messages should appear in catalina.out
精彩评论