有什么我可以添加到pom.xml
的东西,它将生成的.war
文件从target
目录复制到我的Tomcat的webapps
目录吗?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<outputDirectory><!-- Tomcat webapps location--></outputDirectory>
<!-- Example of Tomcat webapps location : U:\JBoss6\server\default\deploy\ -->
</configuration>
</plugin>
</plugins>
</build>
我使用了Maven WAR插件:http://maven.apache.org/plugins/maven-war-plugin/usage.html
这是正确的方法:
您还可以查看码头插件。只需输入“ mvn jetty:run-war”,jetty即可运行您的war文件。
或者,您可以让tomcat在目标目录中查找并直接从那里进行部署。
不太理想,但是如果您有一个非常奇怪的应用服务器设置,则总是可以使用antrun任务集在打包运行时执行]
<build>
....
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<!-- Ant copy tasks go here -->
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
感谢上述所有答案。
您也可以使用dependency plugin进行此操作