正在部署 War。 Tomcat 未考虑 META-INF 中的 context.xml

Deploying War. Tomcat not taking context.xml from META-INF in consideration

我确实有一个 Spring 启动应用程序,它为 tomcat 使用自定义 context.xml。 context.xml 包含 属性,定义 spring 活动配置文件

<Context>
    <Environment name="spring.profiles.active" value="profileName" type="java.lang.String" override="false" />
</Context>

文件位置是 /src/main/webapps/META-INF 我期待在文件部署到 tomcat 后,上下文 xml 将被 tomcat 自动选择并扔到 conf/catalina/localhost/

事实证明,war 已部署,但 conf/catalina/localhost 仍为空。

阅读文档后我发现 server.xml 必须使用 copyXML 参数作为主机容器进行更新。 文档说:

copyXML Set to true if you want a context XML descriptor embedded inside the application (located at /META-INF/context.xml) to be copied to xmlBase when the application is deployed. On subsequent starts, the copied context XML descriptor will be used in preference to any context XML descriptor embedded inside the application even if the descriptor embedded inside the application is more recent. The flag's value defaults to false. Note if deployXML is false, this attribute will have no effect.

我的主机长得像

<Host name="localhost"  appBase="webapps"
                  unpackWARs="true" autoDeploy="true" copyXML="true">
            </Host>

重启服务器并重新部署应用程序后,/conf/Catalina/localhost 仍然是空的。

您有什么建议,必须采取哪些措施才能使用自定义 context.xml?

我已经弄明白了。 我的构建脚本没有正确复制文件,文件名不是 "context.xml" 但 "appName.xml" 和 tomcat 没有选择它。