At the moment, the default I think, it copies to
target/myproject/WEB-INF/classes
so when deploying it does not pick up the context.
Also, i want to reference a server specific config file database.properties, I want to put it in tomcat/conf and then reference it in applicationContext.xml, how can I do this ?
Also(2), I am under the impression that this is a fairly standard and decent way to set things up - please correct me if I am wrong.
edit for the server specific config file I user this
<context:property-placeholder
location="file:${catalina.home}/conf/database.properties"
ignore-unresolvable="true"
/>
If you need to keep applicationContext.xml
as a classpath resource, you can configure ContextLoaderListener
to pick it from the classpath by adding the following lines to web.xml
:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
It's much easier than configuring Maven to copy it to WEB-INF
.
Regarding the second question, you can configure PropertyPlaceholderConfigurer
or <context:property-placeholder>
to load .properties
file from a file system.