作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个 Spring 应用程序,其中的属性文件将打包在 .war 文件中以供部署。
<context:property-placeholder location="classpath:application.properties" />
但是,我希望能够用另一个可以在 standalone.xml 中指定为系统属性的文件覆盖它们:
</extensions>
<system-properties>
<property name="CONFIG_FILE_LOCATION" value="/path/to/application.properties"/>
</system-properties>
这是我的解决方案,
<context:property-placeholder location="classpath:application.properties,
file:///${CONFIG_FILE_LOCATION}" />
但显然 Spring 无法找到它
Caused by: java.io.FileNotFoundException: ${CONFIG_FILE_LOCATION} (The system cannot find the file specified)
有人知道我该如何解决吗? Spring 是否有另一种访问系统属性的方式?
最佳答案
在 Spring
中实际上可以通过使用此解决方案将 system property
位置指定到另一个文件来覆盖某些属性:
<context:property-placeholder location="classpath:alarm_notification.properties, file:///${CONFIG_FILE_LOCATION}" />
如果位于 CONFIG_FILE_LOCATION
的文件中的某个属性未被覆盖,则将使用 application.properties
中的值。
只需确保在用于启动服务器的standalone.bat
文件中具有以下配置:
</extensions>
<system-properties>
<property name="CONFIG_FILE_LOCATION" value="/path/to/application.properties"/>
</system-properties>
关于java - 如何在 Spring 中加载系统属性以获取属性文件位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40930004/
我正在开发一个需要能够平均三个数字的 Facebook 应用程序。但是,它总是返回 0 作为答案。这是我的代码: $y = 100; $n = 250; $m = 300; $number = ($y
我只是无法弄清楚这一点,也找不到任何对我来说有意义的类似问题。我的问题:我从数据库中提取记录,并在我的网页上以每个面板 12 条的倍数显示它们。因此,我需要知道有多少个面板可以使用 JavaScrip
我是一名优秀的程序员,十分优秀!