Tec*_*ind 1 eclipse tomcat maven
pom.xml中:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://localhost:8080/manager/html</url>
<server>myserver</server>
<path>/test</path>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
Eclipse使用:带有m2e插件的 Eclipse indigo 3.7
修改了Tomcat7/conf/tomcat-users.xml
<role rolename="admin"/>
<role rolename="manager"/>
<user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>
Run Code Online (Sandbox Code Playgroud)
Context.xml
Tomcat7/conf/context.xml,更改<context>为
<Context antiJARLocking="true" antiResourceLocking="true">
Run Code Online (Sandbox Code Playgroud)
在apache-maven\conf\settings.xml下
在服务器标签下添加以下条目:
<servers>
<server>
<id>myserver</id>
<username>admin</username>
<password>admin</password>
</server>
Run Code Online (Sandbox Code Playgroud)
启动tomcat服务器.
目标运行:tomcat:deploy和tomcat:undeploy
得到以下错误:
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project test: Cannot invoke Tomcat manager: Server returned HTTP response code: 403 for URL: http://localhost:8080/manager/html/deploy?path=%2Ftest&war=&update=true -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Run Code Online (Sandbox Code Playgroud)
项目名称:测试
war文件名:test-1.0-SNAPSHOT.war
发现了类似的问题,但没有太多用处:Tomcat-maven-plugin 401错误
虽然回答很晚,但有人可能觉得这很有用.如果你使用的是maven3和tomcat7.下面的方法对我有用.我不知道tomcat7中应用程序管理器端点的变化.
Environment - Apache Maven 3.0.4,apache-tomcat-7.0.34,Windows 7
Run Code Online (Sandbox Code Playgroud)
Tomcat7已将其部署终点从更改http://tomcatserver:8080/manager/html为http://tomcatserver:8080/manager/text .
所以我的pom.xml将是
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://tomcatserver:8080/manager/text</url>
<server>tomcat</server>
<path>/myWebApp</path>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
在tomcat-users.xml中
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<user username="root" password="root" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>
Run Code Online (Sandbox Code Playgroud)
在maven settings.xml中
<server>
<id>tomcat</id>
<username>root</username>
<password>root</password>
</server>
Run Code Online (Sandbox Code Playgroud)
在context.xml中,尽管这是可选的并且与maven3部署到tomcat7无关,但有时可能会发生jar锁定,因此要更安全.
<Context antiJARLocking="true" antiResourceLocking="true">
Run Code Online (Sandbox Code Playgroud)
现在发行
mvn tomcat:deploy
Run Code Online (Sandbox Code Playgroud)
记得在maven部署之前启动tomcat.
如果部署成功,您的应用程序将在
http://tomcatserver:8080/myWebApp
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9878 次 |
| 最近记录: |