通过Maven在tomcat9上部署War时出错-Windows

时间:2018-07-14 16:06:36

标签: java maven tomcat

任何帮助将不胜感激,因为此配置可在Mac上运行,但不适用于Windows计算机。

我的命令: mvn全新安装&& mvn tomcat7:redeploy

错误消息:

--- tomcat7-maven-plugin:2.2:redeploy (default-cli) @ web-customer-tracker ---
[INFO] Deploying war to http://localhost:8080/web-customer-tracker
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fweb-customer-tracker&update=true
2692/20011 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fweb-customer-tracker&update=true
2692/20011 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fweb-customer-tracker&update=true
2884/20011 KB
[INFO] I/O exception (java.net.SocketException) caught when processing request: Connection reset by peer: socket write error
[INFO] Retrying request
Uploading: http://localhost:8080/manager/text/deploy?path=%2Fweb-customer-tracker&update=true
2884/20011 KB
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.686 s
[INFO] Finished at: 2018-07-14T21:19:25+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:redeploy (default-cli) on project web-customer-tracker: Cannot invoke Tomcat manager: Connection reset by peer: socket write error -> [Help 1]

Tomcat在端口8080上运行

pom.xml

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <url>http://localhost:8080/manager/text</url>
                    <server>TomcatServer</server>
                    <path>/web-customer-tracker</path>
                </configuration>
            </plugin>
        </plugins>
        <finalName>web-customer-tracker</finalName>
    </build>

〜/ .m2 / settings.xml

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

tomcat-users.xml

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="password" roles="manager-gui,manager-script"/>
</tomcat-users>

Tomcat:9.0.10 专家:3.3.4 JDK:Java版本“ 1.8.0_172”

2 个答案:

答案 0 :(得分:0)

尝试了几乎所有内容后,我在m2中删除了settings.xml。然后我在pom.xml中进行了以下更改

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <url>http://localhost:8080/manager/text</url>
                <server>TomcatServer</server>
                <username>admin</username>
                <password>password</password>
                <path>/web-customer-tracker</path>
            </configuration>
        </plugin>
    </plugins>
    <finalName>web-customer-tracker</finalName>
</build>

我将settings.xml中的用户名和密码添加到pom文件中,并且可以正常工作。请不要在基于UNIX的系统上不会发生此问题。

答案 1 :(得分:0)

这解决了错误 无法调用Tomcat管理器:对等连接重置:套接字写入错误

以管理员身份运行,启动两个单独的命令提示符终端。 在第一个终端中,转到您的tomcat bin目录并运行shutdown.bat,然后运行我的情况下的startup.bat c:\ Program Files \ Apache Software Foundation \ apache-tomcat-8.5.8 \ bin> shutdown.bat c:\ Program Files \ Apache Software Foundation \ apache-tomcat-8.5.8 \ bin> startup.bat

在第二个终端中,转到您的maven webapp目录,然后运行mvn命令。就我而言 mvn tomcat7:deploy

这将是一次成功!!