问题
I'm using Maven in my Java project and I want to deploy the WAR to my localhost Tomcat.
I have this lines in my pom.xml file:
<properties>
<tomcat.target>C:\Directory</tomcat.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webappDirectory>${tomcat.target}</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>
The output logs are:
[INFO] --- maven-install-plugin:2.3.1:install (default-install) ---
[INFO] Installing C:\Directory\name.war to C:\Directory\name.war
[INFO] Installing C:\Directory\pom.xml to C:\Directory\name.pom
As you can see I want to config this line:
to C:\Directory\name.war
How to point it to Tomcat's /webapps folder?
回答1:
<configuration>
<url>http://127.0.0.1:8080/manager</url>
<server>TomcatServer</server>
<path>/mkyongWebApp</path>
</configuration>
check the link http://www.mkyong.com/maven/how-to-deploy-maven-based-war-file-to-tomcat/
回答2:
if you are using netbeans add this to your pom
<properties>
<netbeans.hint.deploy.server>Tomcat70</netbeans.hint.deploy.server>
</properties>
or else you can use these links http://winfig.com/?p=76 and http://www.avajava.com/tutorials/lessons/how-do-i-deploy-a-maven-web-application-to-tomcat.html
回答3:
Using a different Tomcat manager URL
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.2-SNAPSHOT</version>
<configuration>
<url>http://www.example.com:1234/mymanager</url>
</configuration>
</plugin>
...
</plugins>
...
</build>
...
</project>
See the usage page.
来源:https://stackoverflow.com/questions/15474098/how-to-deploy-war-file-to-tomcat-using-maven