如何使用 maven 将文件复制到 tomcat webapp 文件夹?
我想使用 Maven 将资源文件从 src/main/resources 复制到 /target/tomcat6x/container/webapps 中的 Cargo
Tomcat
。
我尝试使用 maven-resources-plugin
但没有取得任何成功。
我尝试了这个:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.5</version>
<configuration>
<wait>false</wait>
<container>
<containerId>tomcat6x</containerId>
<zipUrlInstaller>
<url>
http://mirrors.enquira.co.uk/apache/tomcat/tomcat-6/v6.0.30/bin/apache-tomcat-6.0.30.zip
</url>
<installDir>${installDir}</installDir>
</zipUrlInstaller>
<output>
${project.build.directory}/tomcat6x.log
</output>
<log>${project.build.directory}/cargo.log</log>
</container>
<configuration>
<files>
<copy>
<file>src/main/resources/datasource.properties</file>
<!--tofile>${project.build.directory}/tomcat6x/container/webapps/datasource.properties</tofile-->
<todir>${project.build.directory}/tomcat6x/container/webapps</todir>
</copy>
</files>
<home>
${project.build.directory}/tomcat6x/container
</home>
<properties>
<cargo.logging>high</cargo.logging>
<cargo.servlet.port>8081</cargo.servlet.port>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>configure</goal>
<goal>start</goal>
<goal>deploy</goal>
</goals>
<configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<pingURL>http://localhost:8081/charmweb-0.0.1-SNAPSHOT/</pingURL>
<pingTimeout>180000</pingTimeout>
<properties>
<context>charmweb-0.0.1-SNAPSHOT</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
...但是在服务器启动并且应用程序被 ping 之前文件没有复制。
有谁知道如何正确使用它?
I want to copy a resource file from src/main/resources to Cargo
Tomcat
in /target/tomcat6x/container/webapps using Maven
.
I tried using maven-resources-plugin
but am not having any success.
I tried this:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.5</version>
<configuration>
<wait>false</wait>
<container>
<containerId>tomcat6x</containerId>
<zipUrlInstaller>
<url>
http://mirrors.enquira.co.uk/apache/tomcat/tomcat-6/v6.0.30/bin/apache-tomcat-6.0.30.zip
</url>
<installDir>${installDir}</installDir>
</zipUrlInstaller>
<output>
${project.build.directory}/tomcat6x.log
</output>
<log>${project.build.directory}/cargo.log</log>
</container>
<configuration>
<files>
<copy>
<file>src/main/resources/datasource.properties</file>
<!--tofile>${project.build.directory}/tomcat6x/container/webapps/datasource.properties</tofile-->
<todir>${project.build.directory}/tomcat6x/container/webapps</todir>
</copy>
</files>
<home>
${project.build.directory}/tomcat6x/container
</home>
<properties>
<cargo.logging>high</cargo.logging>
<cargo.servlet.port>8081</cargo.servlet.port>
</properties>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>configure</goal>
<goal>start</goal>
<goal>deploy</goal>
</goals>
<configuration>
<deployer>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<pingURL>http://localhost:8081/charmweb-0.0.1-SNAPSHOT/</pingURL>
<pingTimeout>180000</pingTimeout>
<properties>
<context>charmweb-0.0.1-SNAPSHOT</context>
</properties>
</deployable>
</deployables>
</deployer>
</configuration>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
... but the file is not copying before the server starts and the application gets pinged.
Does anyone know how to use it properly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 maven-antrun-plugin 来执行此操作并执行 ant 复制任务:
You can use the maven-antrun-plugin for this and execute an ant copy task:
好的,这是答案:
ok here is the answer.: