问题
This is my pom.xml
build configuration:
<build>
<finalName>cfwd</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<url>http://xx.xxx.xxx.xxx:8080/manager/text</url>
<server>cifServer</server>
<path>/cfwd</path>
<addContextWarDependencies>true</addContextWarDependencies>
<addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
where http://xx.xxx.xxx.xxx:8080
is the remote server IP.
When I try to deploy via mvn tomcat:deploy
I get this error:
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project cfwd: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL:
http://localhost:8080/manager/deploy?path=%2Fcfwd&war=
-> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project cfwd: Cannot invoke Tomcat manager
where it looks like maven is attempting to deploy to localhost:8080
rather than the remote server IP. Any idea?
回答1:
You need to execute mvn tomcat7:deploy
(note the '7') in order to trigger the plugin you've configured.
See this page for more information about the available goals.
回答2:
403 means Forbidden.
Check with the official documentation in order to configure authentication to the Tomcat manager (parameters Server, password, username).
Duncan Jones is right : you are not executing the correct plugin : use tomcat7.
来源:https://stackoverflow.com/questions/13725945/maven-attempting-to-deploy-to-localhost-instead-of-remote-server