当前位置: 首页 > 知识库问答 >
问题:

使用maven将web应用程序部署到tomcat服务器

陶高扬
2023-03-14

pom.xml我有这个用来部署

    <distributionManagement>
        <repository>
            <id>TomcatLocalServer</id>
            <url>http://localhost:8080/manager</url>
        </repository>
    </distributionManagement>
    <build>
      <plugins>
          <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://localhost:8080/manager</url>
                    <server>TomcatLocalServer</server>
                    <path>/SCPI</path>
                </configuration>
                </plugin>
          </plugins>
    </build>

在设置中。tomcat服务器的xml我有这个

        <server>
            <id>TomcatLocalServer</id>
            <username>andrfas</username>
            <password>1234</password>
        </server>

当我试图调用maven deploy时,出现了一个错误:

Uploading: http://localhost:8080/manager/ua/andrfas/SCPI/0.0.1/SCPI-0.0.1.war
184/34421 KB   мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset by peer: socket write error
мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:8080
256/34421 KB   мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset by peer: socket write error
мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:8080
мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8080: Connection reset by peer: socket write error
мар 13, 2015 4:04:17 PM org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec execute
INFO: Retrying request to {}->http://localhost:8080
Uploading: http://localhost:8080/manager/ua/andrfas/SCPI/0.0.1/SCPI-0.0.1.pom
  [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project SCPI: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project SCPI: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
    Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
        at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:193)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 25 more
    Caused by: org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
        at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
        at org.apache.maven.plugin.deploy.AbstractDeployMojo.deploy(AbstractDeployMojo.java:167)
        at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:157)
        ... 27 more
    Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
        at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:317)
        at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:245)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
        at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
        ... 29 more
    Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact ua.andrfas:SCPI:war:0.0.1 from/to TomcatLocalServer (http://localhost:8080/manager): Connection reset by peer: socket write error
        at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:43)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector.put(BasicRepositoryConnector.java:274)
        at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:311)
        ... 32 more
    Caused by: org.apache.maven.wagon.TransferFailedException: Connection reset by peer: socket write error
        at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:662)
        at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:557)
        at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:539)
        at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:533)
        at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:513)
        at org.eclipse.aether.transport.wagon.WagonTransporter$PutTaskRunner.run(WagonTransporter.java:644)
        at org.eclipse.aether.transport.wagon.WagonTransporter.execute(WagonTransporter.java:427)
        at org.eclipse.aether.transport.wagon.WagonTransporter.put(WagonTransporter.java:410)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$PutTaskRunner.runTask(BasicRepositoryConnector.java:510)
        at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:350)
        ... 34 more
    Caused by: java.net.SocketException: Connection reset by peer: socket write error
        at java.net.SocketOutputStream.socketWrite0(Native Method)
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
        at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:123)
        at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionOutputBufferImpl.flushBuffer(SessionOutputBufferImpl.java:135)
        at org.apache.maven.wagon.providers.http.httpclient.impl.io.SessionOutputBufferImpl.write(SessionOutputBufferImpl.java:164)
        at org.apache.maven.wagon.providers.http.httpclient.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:115)
        at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon$RequestEntityImplementation.writeTo(AbstractHttpClientWagon.java:204)
        at org.apache.maven.wagon.providers.http.httpclient.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:155)
        at org.apache.maven.wagon.providers.http.httpclient.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:149)
        at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:236)
        at org.apache.maven.wagon.providers.http.httpclient.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:121)
        at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.MainClientExec.execute(MainClientExec.java:254)
        at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.ProtocolExec.execute(ProtocolExec.java:195)
        at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RetryExec.execute(RetryExec.java:86)
        at org.apache.maven.wagon.providers.http.httpclient.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
        at org.apache.maven.wagon.providers.http.httpclient.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.execute(AbstractHttpClientWagon.java:848)
        at org.apache.maven.wagon.providers.http.AbstractHttpClientWagon.put(AbstractHttpClientWagon.java:607)
        ... 43 more

服务器正在运行。我试图在pom中更改tomcat插件。xml到tomcat7 maven插件,但我得到了相同的错误。据我所知,它正试图将war文件部署到http://localhost:8080/manager/ua/andrfas/SCPI/0.0.1/SCPI-0.0.1.战争这是真的吗?如果是,为什么?我做错了什么?

共有1个答案

欧阳楚
2023-03-14

所以,这里有一个解决我的问题的方法:

将插件更改为tomcat7 maven插件:

<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>TomcatLocalServer</server>
                    <path>/SCPI</path>
                    <username>andrfas</username>
                    <password>1234</password>
                    <update>true</update>
                </configuration>
            </plugin>

请注意url-http://localhost:8080/manager/text不http://localhost:8080/manager/html

在tomcat用户中。添加xml

<user username="andrfas" password="1234" roles="manager-script"/>

请注意角色管理器脚本,而不是管理器gui。

最后,根据上面列出的插件运行mvn tomcat7:deploy。只是要小心运行正确版本的插件。

 类似资料:
  • 我期待着在tomcat 7前面的apache超文本传输协议服务器,以呈现我的静态内容,以获得更好的性能和可扩展性。 现在使用pom,我能够部署到tomcat完全战争。 但我找不到任何可以启动http服务器并向其部署静态内容的插件。 基本上,我希望过滤静态资源,并将其部署到http服务器,同时以。把war文件发给tomcat。 我寻找类似的东西与嵌入式apache超文本传输协议服务器插件或东西。 动

  • 我正在尝试使用Visual Studio代码将java web应用程序部署到Tomcat,我有一些问题想与大家分享。 在安装了Tomcat for Java扩展之后,我尝试部署了一个Maven Java Web项目。为此,我点击了项目的文件夹并选择了“在Tomcat服务器上运行”选项。结果是出现以下错误消息:< code >该文件夹不是在Tomcat服务器上运行的有效web应用程序。 然后,我意识

  • 如何使用VSTS版本将war文件部署到运行Tomcat的Azure Web应用程序?我在VSTS设置中有一个CI/CD管道,在提交代码时进行构建,然后在构建完成时发布新的war文件并将其推送到Azure。问题是,war文件被部署到\site\wwwroot\webapps,而不是\site\wwwroot\bin\apache-tomcat-8.5.24\webapps,需要将其作为应用程序拉入t

  • 我想部署两个应用程序foo。war和条形图。war到同一个Tomcat实例。他们是否可以侦听不同端口上的连接,例如,foo侦听端口81,bar侦听端口82?如果是,我如何配置?我意识到应用程序没有必要监听不同的端口,但这正是我想要实现的。 此外,如果我将重命名为,使其在根上下文中运行,那么对该Tomcat实例的所有请求都将由foo应用程序处理,因此bar必须部署到单独的Tomcat实例,这是否正确

  • 我试图用netbeans和Tomcat8部署java应用程序。单击debug时,在“Apache Tomcat或Tomee”选项卡中出现异常: 用netbeans和Tomcat进行部署还有另一种方法吗?我不想总是用Sudo从控制台运行netbeans。

  • 问题内容: 我已经创建了Spring Boot Web应用程序,但是无法在tomcat上部署Spring Boot Web应用程序WAR文件,并且能够将其作为Java应用程序运行。如何在tomcat上将Spring Boot应用程序作为Web服务运行 我正在使用以下代码。如果可以在tomcat plz上运行,请帮助我使用批注而不使用web.xml和web.xml。 以下代码用于休息控制器 我正在使