Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Cargo-embedded-tomcat:custom-context.xml_Java_Maven_Tomcat_Cargo - Fatal编程技术网

Java Cargo-embedded-tomcat:custom-context.xml

Java Cargo-embedded-tomcat:custom-context.xml,java,maven,tomcat,cargo,Java,Maven,Tomcat,Cargo,我正在使用cargo在Tomcat上自动化战争部署。然而,我遇到了一个问题:我不能用我的自定义文件替换默认的tomcat文件,因为我的文件首先被复制,然后在默认情况下被覆盖。我花了几个小时来解决这个问题,但没有什么用。这是我的pom.xml <artifactId>maven-resources-plugin</artifactId> <executions>

我正在使用cargo在Tomcat上自动化战争部署。然而,我遇到了一个问题:我不能用我的自定义文件替换默认的tomcat文件,因为我的文件首先被复制,然后在默认情况下被覆盖。我花了几个小时来解决这个问题,但没有什么用。这是我的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>
maven资源插件
替换tomcat用户xml
过程测试资源
复制资源
${basedir}/target/apachetomcat-${version.tomcat}/conf/
src/测试/资源/
context.xml
替换tomcat用户xml货物
过程测试资源
复制资源
${basedir}/target/cargo/installs/tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}
src/测试/资源/
context.xml
这是货物使用:

<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>

org.codehaus.cargo
cargo-maven2-plugin
1.4.11
假的
tomcat7x
${project.build.directory}/cargo.log
org.apache.tomcat
雄猫
${version.tomcat}
拉链
${basedir}/target/cargo/installs/apache-tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}
${basedir}/target/cargo/installs/apache-tomcat-${version.tomcat}/apache-tomcat-${version.tomcat}
mysql
mysql连接器java
${basedir}/target/cargo/installs/context.xml
形态/
context.xml
真的
真的
8080
admin:admin:manager脚本
-Xmx1024m-XX:MaxPermSize=512m
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
-Xnoagent
-Djava.compiler=NONE
解决方案之一是:

我的工作配置(使用jdbc数据源池)如下所示:

        <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>

org.codehaus.cargo
cargo-maven2-plugin
1.5.0
tomcat8x
UTF-8
tomcat,datajpa
org.postgresql
postgresql
src/main/resources/tomcat/context.xml
conf/Catalina/localhost/
context.xml.default
ru.javawebinar
托普爪哇
战争
${project.build.finalName}

我看到我没有这里的标签,但我已经做了,所以不要在这里寻找错误。主要的问题是,嵌入的tomcat稍后会复制我的自定义文件并覆盖它们。