开发者

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

I'm trying to underst开发者_StackOverflowand 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜