【发布时间】:2011-06-10 07:29:44
【问题描述】:
我希望当我运行 mvn install 时,可以在 /target 中生成一个战争,并在 c:..tomcat 6\deploy 目录中生成另一个战争。 我正在使用 maven2、Eclipse 和 m2eclipse。这该怎么做 ?? 谢谢 :)
【问题讨论】:
我希望当我运行 mvn install 时,可以在 /target 中生成一个战争,并在 c:..tomcat 6\deploy 目录中生成另一个战争。 我正在使用 maven2、Eclipse 和 m2eclipse。这该怎么做 ?? 谢谢 :)
【问题讨论】:
您可以尝试使用maven-antrun-plugin 将您的战争复制到tomcat 部署目录,如下所示:
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<copy file="{project.build.directory}/${project.actifactId}-${project.version}.war" tofile="<your tomcat path>/${project.actifactId}-${project.version}.war" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
【讨论】:
如果您尝试Maven Jetty Plugin,也许您不需要复制战争文件。此插件用于直接从 Maven 运行 Web 应用程序。
【讨论】:
试试cargo-maven2-plugin。可能这样的事情会起作用:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
<execution>
<id>deploy-local</id>
<phase>install</phase>
<goals>
<goal>deployer-deploy</goal>
<goals>
</execution>
</executions>
<configuration>
<container>
<containerId>tomcat6x</containerId>
</container>
<configuration>
<type>existing</type>
<home>/your/tomcat/dir</home> <!-- replace as needed -->
</configuration>
</configuration>
</plugin>
... 将其放入个人资料或顶级 <build><plugins> 部分,看看它是否适合您...
【讨论】:
finalName 值。但我不完全确定。