货物嵌入式tomcat:自定义context.xml [英] Cargo embedded tomcat: custom context.xml
本文介绍了货物嵌入式tomcat:自定义context.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用货物来自动化Tomcat上的战争部署。但是,我遇到了麻烦:我不能用我的自定义替换默认的tomcat文件,因为我的文件首先被复制然后默认被覆盖。我花了几个小时来解决这个问题,但没有任何作用。这是我的pom.xml
I am using cargo to automate war deployment on Tomcat. However, i get a trouble: i can`t replace default tomcat files with my custom as my files are copied first and then get overwritten by default. I spent hours for resolving this problem but nothing works. Here is my pom.xml
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>replace-tomcat-users-xml</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/apache-tomcat-${version.tomcat}/conf/</outputDirectory>
<resources>
<resource>
<directory>src/test/resources/</directory>
<includes>
<include>context.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>replace-tomcat-users-xml-cargo</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/cargo/installs/tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}</outputDirectory>
<resources>
<resource>
<directory>src/test/resources/</directory>
<includes>
<include>context.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
这里的货物使用:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.11</version>
<configuration>
<skip>false</skip>
<container>
<containerId>tomcat7x</containerId>
<log>${project.build.directory}/cargo.log</log>
<artifactInstaller>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat</artifactId>
<version>${version.tomcat}</version>
<type>zip</type>
</artifactInstaller>
<systemProperties>
<tomcat.home.dir>
${basedir}/target/cargo/installs/apache-tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}
</tomcat.home.dir>
<tomcat.server.home.dir>
${basedir}/target/cargo/installs/apache-tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}
</tomcat.server.home.dir>
</systemProperties>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
</container>
<configuration>
<configfile>
<file>${basedir}/target/cargo/installs/context.xml</file>
<todir>conf/</todir>
<tofile>context.xml</tofile>
<configfile>true</configfile>
<overwrite>true</overwrite>
</configfile>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<!--Тут менять-->
<cargo.servlet.users>admin:admin:manager-script</cargo.servlet.users>
<cargo.jvmargs>
-Xmx1024m -XX:MaxPermSize=512m
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
-Xnoagent
-Djava.compiler=NONE
</cargo.jvmargs></properties>
</configuration>
推荐答案
其中一个解决方案是:是否可以提供Tomcat6的上下文.xml文件通过Maven Cargo插件?
One of solution is here: Is it possible to supply Tomcat6's context.xml file via the Maven Cargo plugin?
我的工作配置(使用jdbc DataSource池)如下所示:
My working configuration (with jdbc DataSource pool) looks like:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<systemProperties>
<file.encoding>UTF-8</file.encoding>
<spring.profiles.active>tomcat,datajpa</spring.profiles.active>
</systemProperties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>
</container>
<configuration>
<configfiles>
<configfile>
<file>src/main/resources/tomcat/context.xml</file>
<todir>conf/Catalina/localhost/</todir>
<tofile>context.xml.default</tofile>
</configfile>
</configfiles>
</configuration>
<deployables>
<deployable>
<groupId>ru.javawebinar</groupId>
<artifactId>topjava</artifactId>
<type>war</type>
<properties>
<context>${project.build.finalName}</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
这篇关于货物嵌入式tomcat:自定义context.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文