简体   繁体   中英

Is there a good reason why Spring Roo puts database.properties in META-INF/spring?

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?

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM