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

标签 spring ssl jenkins spring-security

这太疯狂了......

我有一个 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/

相关文章:

spring - 什么是 'weaving' ?

java - 本地主机上的 SSLPeerUnverifiedException : peer not authenticated with self signed certificates in netbeans 8. 2

sql-server - 将 SymmetricDS 连接到 ParaSQL

java - 为什么 Jenkins 遇到 UTF 8 问题

ios - 从 MAC 上的 launchDaemon 运行的 Bash 脚本 - 未连接到 jenkins

java - 如何使用注释在 Spring 中加载系统属性?

spring - RestTemplate 所需的 MultipartFile 参数 'file' 不存在

java - Spring Boot和Spring Cloud配置客户端错误

actionscript-3 - 在 AS3/Flash 中,URL 请求/加载程序可以在不指定 http 或 https 协议(protocol)的情况下使用 "//"吗?

bash - 如何以 root 身份在远程机器上运行来自 Jenkins 的命令?