gpt4 book ai didi

tomcat - 在tomcat7上用maven部署

转载 作者:行者123 更新时间:2023-11-28 21:51:34 25 4
gpt4 key购买 nike

您好,我正在尝试使用 Maven 部署我的应用程序。通过网络界面部署炒锅。但是 Maven 首先取消部署应用程序(这是正确的)然后在日志消息“已上传”处停止大约 30 秒并失败:

tomcat7:部署

[INFO] Deploying war to http://192.168.1.137:8080/Application
Uploading: http://192.168.1.137:8080/manager/html/deploy?path=%2FApplication&update=true
Uploaded: http://192.168.1.137:8080/manager/html/deploy?path=%2FApplication&update=true (17575 KB at 23215.6 KB/sec)

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 57.061s
[INFO] Finished at: Mon Aug 06 09:41:27 CEST 2012
[INFO] Final Memory: 19M/220M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-beta-1:deploy (default-cli) on project Application: Cannot invoke Tomcat manager: The target server failed to respond -> [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

我的 pom.xml 中的配置

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<url>http://192.168.1.137:8080/manager/html</url>
<username>admin</username>
<password>password</password>
<path>/Application</path>
<update>true</update>
</configuration>
</plugin>

我也用 tomcat:redeploy 尝试了旧插件:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://192.168.1.137:8080/manager/html</url>
<username>admin</username>
<password>password</password>
<path>/Application</path>
</configuration>
</plugin>

但它也失败了:

[ERROR] Failed to execute goal org.codehaus.mojo:tomcat-maven-plugin:1.1:redeploy (default-cli) on project Application: Cannot invoke Tomcat manager: Unexpected end of file from server -> [Help 1]

是否可以更改部署超时?也许我的应用需要很长时间才能启动

编辑:我发现当我 checkout 项目并在运行 tomcat 的同一台机器上运行 tomcat7:deploy 时它可以工作

最佳答案

虽然回答晚了,但有人可能会觉得这很有用。如果您使用的是 maven3 和 tomcat7。下面的方法对我有用。我不知道 tomcat7 中应用程序管理器端点的变化。

Environment - Apache Maven 3.0.4,apache-tomcat-7.0.34,Windows 7

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>

在 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"/>

在 maven settings.xml 中

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

在 context.xml 中,虽然这是可选的,与 maven3 部署到 tomcat7 无关,但有时可能会发生 jar 锁定,所以为了安全起见。

<Context  antiJARLocking="true" antiResourceLocking="true">

现在发布

mvn tomcat:deploy

maven部署前记得启动tomcat

如果部署成功,您的应用程序将在

http://tomcatserver:8080/myWebApp

关于tomcat - 在tomcat7上用maven部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11824365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com