Reputation: 1157
I use maven. My web application contains two modules and each has it's own spring context. First is packed to jar, the second one to war. The second one uses first module's jar and calls it's methods.
I need to add property file, which will be used by first module (via spring context). The main issue is that I should be able to access/edit this property file after war deployment.
How can I provide such a property file, that will be used in first jar module and can be changed after war module deployment?
Thanks.
Upvotes: 3
Views: 4839
Reputation: 23535
Sorry, don't see the problem, you need to describe that better. From what I understood this is the way to go:
a.properties
in src/main/resources
in the JAR modulePropertyPlaceholderConfigurer
to make the properties available in the Spring contextWEB-INF/lib
of the WAR which again is "root of the classpath" so to speakUpdate, 2013-06-09
(question was updated based on comments to initial answer above)
Essentially what you seem to be looking for (still not quite sure) is how to load properties from a properties file that is not packaged with your WAR/JAR.
In this case you can skip all of the above steps except 2.
PropertyPlaceholderConfigurer
and specify the location of the file as classpath*:a.properties
(see below)a.properties
anywhere on the classpath outside the WAR file.Warning! Of course you can now edit the properties independently from releasing the WAR file but since Spring initializes the beans on application start and since all beans are singletons by default changes to the properties file won't become effective until you restart the app.
XML example
<bean class="....PropertyPlaceholderConfigurer">
<property name="location" value="classpath*:a.properties" />
Upvotes: 2