简体   繁体   中英

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

I do have a Spring Boot Application which uses custom context.xml for the tomcat. The context.xml contains property, defining the spring active profile

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

File location is the /src/main/webapps/META-INF I was expecting that after the file is deployed to the tomcat, context xml will be automatically picked by tomcat and thrown to the conf/catalina/localhost/

As it turned out, the war was deployed, but the conf/catalina/localhost stayed empty.

After reading the docs i've found out that the server.xml has to be updated with the copyXML parameter as Host container. The documentation says:

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.

My Host looks like

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

After restarting the server and redeploying the app, the /conf/Catalina/localhost still stayed empty.

Do you have any suggestions, what actions have to be taken in order to use custom context.xml?

I've figured it out. My build script did not copy the file correctly, the file name was not "context.xml" but "appName.xml" and tomcat didn't pick it up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM