Jenkins 正在用它的系统属性更新我的 applicationContext.xml 文件?

Jenkins is updating my applicationContext.xml file with it's system properties?

这太疯狂了...

我有一个 applicationContext.xml,它使用系统属性配置一个 bean。

在我的例子中,我正在配置一个 bean 以从文件中注入值,或者如果没有,请查看 system.properties(我希望这只会在 运行 时间发生!)

我有:

<bean id="myBean" class="foo.foo.fooBarImpl">
  <property name="keyStoreFile" value="${javax.net.ssl.KeyStore}"/>
...
...
</bean>

因此,当我的 java 应用程序使用此 applicationContext.xml(驻留在类路径中的 jar 中)启动时,它将从属性文件中提取 ${javax.net.ssl.KeyStore},或者如果属性文件不存在,请尝试从系统属性中获取它。

我无法解释的是……当詹金斯从存储库中拉取并构建…… 它正在修改我的 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>