java - 部署 war 。 Tomcat 没有考虑 META-INF 中的 context.xml

标签 java spring-boot tomcat deployment tomcat9

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

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

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

事实证明, war 已经部署,但是 conf/catalina/localhost 仍然是空的。

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

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 没有拾取它。

关于java - 部署 war 。 Tomcat 没有考虑 META-INF 中的 context.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58389644/

相关文章:

java - 为什么 Math.abs() 返回 25 并说没有显式返回值?

java - 如何使用 JList 以粗体打印项目的一部分

java - ResponseEntityExceptionHandler 的 Spring 依赖

java - SSL 身份验证/授权是否是握手的一部分?

tomcat - 在 apache 中启用 mod_deflate

java - 为什么 String 被视为抽象数据类型?

java - Tomcat 日志远程访问

java - 如何从包含的文件中删除/禁用/覆盖附加程序?

java - java中的超时值超过启动取消azure函数

java - 无法在 Eclipse Oxygen 中启动 Tomcat 服务器