spring - 使用本地属性文件覆盖 Spring 3.1 中的属性

标签 spring deployment properties

我正在尝试使用我正在部署的机器上的本地属性文件来覆盖我的 war 文件中找到的默认值。

<context:property-placeholder
  location="classpath*:*.properties, file:/var/myfolder/local.properties"
  ignore-resource-not-found="true"
  ignore-unresolvable="true" />

我发现这可以通过提供一个文件作为第二个位置(逗号分隔)来实现。不幸的是,它似乎没有覆盖属性。

我尝试过使用属性定义 bean 并设置位置,但这也不起作用。

最佳答案

一种方法是将它们分成两部分并使用顺序

<context:property-placeholder
  location="classpath*:*.properties"
  ignore-resource-not-found="true"
  ignore-unresolvable="true"
  order ="0" />

<context:property-placeholder
  location="file:/var/myfolder/local.properties"
  ignore-resource-not-found="true"
  ignore-unresolvable="true"
  order="-1"/>

最低顺序优先

关于spring - 使用本地属性文件覆盖 Spring 3.1 中的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11645360/

相关文章:

properties - 确保数组属性的每个元素都符合 React 中的自定义形状

java - 在 Spring CrudRepository 中使用 List<Long> 作为参数

java - eclipse spring boot 启动项目给出错误

java - 如何手动将WAR部署到JBOSS 5?

ASP.NET连接字符串部署最佳实践

JavaFX DoubleProperty intValue() 方法始终返回 0,其中返回 0....100

java - 由于 NoSuchAlgorithmException,无法读取 tc 服务器属性 [PropertyDecoder]

spring - 在Spring 3中编译classfile问题

windows-phone-7 - 我无法在手机上部署我的应用程序

ios - readwrite 和 readonly 互斥