【问题标题】:Is there a good reason why Spring Roo puts database.properties in META-INF/spring?Spring Roo 将 database.properties 放在 META-INF/spring 中有充分的理由吗?
【发布时间】:2010-09-18 22:06:49
【问题描述】:

我试图了解 Spring Roo 将 database.properties 放置在 META-INF/spring 中的原因,它将作为 WAR 的一部分部署在其中。

当然,数据库属性是特定于环境的,应该在 WAR 之外,可以在不重建的情况下更改它们?我即将更改 application-context.xml 中的行以在类路径上的任何位置搜索属性文件并将文件移动到不会与 WAR 一起打包的位置。

有什么我没有到达这里会让我后悔吗?

【问题讨论】:

    标签: java spring spring-roo


    【解决方案1】:

    我已经使用 Spring 的 PropertyPlaceholderConfigurer 处理了这个问题,并在类路径中包含属性文件,在文件系统中包含一个属性文件:

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

    如果在应用程序启动(或运行测试等)时当前目录中有 myapp*.properties 文件,它将覆盖烘焙到 war/ear/whatever 中的文件的属性。您可以取出星星,但您必须拥有该文件。

    【讨论】:

      【解决方案2】:

      这可能会影响(破坏)各种database commands

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

      IMO,你应该把它放在META-INF/spring 下。

      【讨论】:

      • 我预计 Roo 会在 application-context.xml 告诉它的任何地方查找 .properties 文件:/
      • 其实从源码来看,Pascal 是对的; Roo 期望该文件位于默认位置。
      猜你喜欢
      • 1970-01-01
      • 2020-11-03
      • 1970-01-01
      • 2017-05-02
      • 1970-01-01
      • 2017-09-21
      • 2016-10-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多