这太疯狂了......
我有一个 applicationContext.xml
,它使用系统属性配置一个 bean。
在我的例子中,我正在配置一个 bean 以从文件中注入(inject)值,如果没有,则查看 system.properties(我希望这只会在运行时发生!)
我有:
<bean id="myBean" class="foo.foo.fooBarImpl">
<property name="keyStoreFile" value="${javax.net.ssl.KeyStore}"/>
...
...
</bean>
因此,当我使用此 applicationContext.xml
(驻留在类路径中的 jar 中)的 java 应用程序启动时,它将拉取 ${javax.net.ssl.KeyStore}
code> 来自属性文件,或者如果属性文件不存在,则尝试从系统属性中获取它。
我无法解释的是……当 jenkins 从存储库中拉取并构建时……
它正在修改我的 applicationContext.xml
!并实际写入系统属性中存在的内容......并在构建 .jar 之前保存它!我的 jar 现在作为 SSL 信息的硬编码值(比如密码......)
<bean id="myBean" class="foo.foo.fooBarImpl">
<property name="keyStoreFile" value="/mympath/keystore.jks"/>
...
...
</bean>
上面修改的 applicationContext.xml 现在在我的 .jar 中!?
Spring 或 Jenkins(也许)中是否有设置来防止我的 applicationContext.xml
被修改并重新保存到 .jar 中?
最佳答案
您是否在构建中使用 Maven?
可能是 Maven 资源过滤正在发生。
请在 pom.xml 上尝试类似的东西
<project>
...
<build>
...
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/applicationContext.xml</include>
</includes>
</resource>
...
</resources>
...
</build>
...
</project>
关于spring - Jenkins 正在用它的系统属性更新我的 applicationContext.xml 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27924790/