views:

84

answers:

2

I'm trying to understand the reasoning behind why Spring Roo places database.properties in META-INF/spring, where it will be deployed as part of the WAR.

Surely database properties are environment specific and should be outside a WAR where they can be changed without rebuilding? I'm about to change the line in application-context.xml to search for properties files anywhere on the classpath and move the file to where it won't be packaged with the WAR.

Is there something I'm not getting here that will make me regret this?

+1  A: 

This will probably affect (break) various database commands like

  • database properties set
  • database properties remove
  • database properties list

IMO, you should keep it under META-INF/spring.

Pascal Thivent
I expected that Roo would look for .properties files anywhere that application-context.xml tells it to :/
Fritz Meissner
+1  A: 

I have handled this using Spring's PropertyPlaceholderConfigurer and including property files on the classpath and one on the filesystem:

<context:property-placeholder 
    location="classpath*:META-INF/spring/*.properties,file:myapp*.properties"/>

If there is a myapp*.properties file in the current directory when the app starts (or tests are run etc.) it will override properties from files baked into the war/ear/whatever. You could take out the star but then you will have to have the file present.

David Tinker