【发布时间】:2011-11-12 09:17:53
【问题描述】:
我正在学习 tomcat 基础知识,当我尝试在 tomcat 上部署我的 web 应用程序时,我收到以下错误
[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:deploy (default-cli) on project struts2-demoapp: Cannot invoke Tomcat manager: Server returned HTTP response code: 401 for URL: http://localhost:8080/manager/html/deploy?path=%2FmkyWebApp&war= -> [Help 1]
[ERROR]
据此看来,war 文件位置没有传递给 tomcat 管理器。我的tomcat-user.xml中有以下条目
tomcat-users>
<user name="admin" password="admin" roles="admin,manager" /><!--
NOTE: The sample user and role entries below are wrapped in a comment
and thus are ignored when reading this file. Do not forget to remove
<!.. ..> that surrounds them.
-->
<role rolename="manager"/>
<role rolename="admin"/>
<user username="admin" password="admin" roles="admin,manager"/>
</tomcat-users>
这里是pom.xml的详细信息
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<warFile>${project.build.directory}/${project.build.finalName}.war</warFile>
<url>http://localhost:8080/manager/html</url>
<server>myserver</server>
<path>/mkyWebApp</path>
</configuration>
</plugin>
</plugins>
</build>
在我的 setting.xml 中有条目
<server>
<id>Tomcat6.x</id>
<username>admin</username>
<password>admin</password>
</server>
我不确定这里到底出了什么问题。这方面的任何帮助都会有所帮助。
【问题讨论】:
-
尝试在 settings.xml 的 'id' 字段中放入 'localhost' 而不是 'Tomcat6.x'。
-
@Tarlog:使用localhost是什么概念?因为使用这个值解决了这个问题所以我想知道
-
我会添加一个明确的答案:)
标签: maven-2 maven maven-plugin maven-3