一尘不染

Maven项目中的Tomcat部署问题

tomcat

我一直试图创建一个简单的基于Maven
Web的项目,以对Maven充满信心。我在pom.xml中添加了tomcat7插件以将其用作服务器。但是当我开始通过使用将我的war文件部署到tomcat时

tomcat7:部署

它抛出如下错误,

[INFO] Deploying war to http://127.0.0.1:8080/MavenWeb  
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.585s
[INFO] Finished at: Wed Jan 30 16:03:06 IST 2013
[INFO] Final Memory: 9M/24M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy  (default-cli) on project MavenWeb: Cannot invoke Tomcat manager: Connection to http://127.0.0.1:8080 refused: Connection refused -> [Help 1]

我在pom.xml中的插件部分如下。

<plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.0</version>
    <configuration>
       <url>http://127.0.0.1:8080/manager/html</url>
       <warFile>/home/shebin/Maven Folder/MavenWeb/target/MavenWeb.war</warFile>
   <server>TomcatServer</server>
       <path>/MavenWeb</path>
   <username>tomcat</username>
       <password>tomcat</password>
    </configuration>
</plugin>

.m2 / settings.xml和/home/shebin/apache-maven-3.0.4/conf/settings.xml

<server>
        <id>TomcatServer</id>
        <username>tomcat</username>
        <password>tomcat</password>
</server>

/home/shebin/apache-tomcat-7.0.35/conf/tomcat-users.xml

<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

我经历了各种解决方案,但没有任何进展。我的Maven版本是3.0.4,并使用tomcat7插件。


阅读 227

收藏
2020-06-16

共1个答案

一尘不染

此错误讯息

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0:deploy  (default-cli) on project MavenWeb: Cannot invoke Tomcat manager: Connection to http://127.0.0.1:8080 refused: Connection refused -> [Help 1]

暗示这与身份验证有关。尝试改变这个

<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-script"/>

通过基于浏览器的管理客户端无法通过Maven插件进行访问:)

2020-06-16