Quantcast
Viewing all articles
Browse latest Browse all 2

Answer by Marcel Stör for Accessing properties file from another module context

Sorry, don't see the problem, you need to describe that better. From what I understood this is the way to go:

  1. place a.properties in src/main/resources in the JAR module
  2. use a PropertyPlaceholderConfigurer to make the properties available in the Spring context
  3. it'll be packed in root of the JAR
  4. the JAR ends up in WEB-INF/lib of the WAR which again is "root of the classpath" so to speak

Update, 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.

  1. Use a PropertyPlaceholderConfigurer and specify the location of the file as classpath*:a.properties (see below)
  2. Place 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" />

Viewing all articles
Browse latest Browse all 2

Trending Articles