gpt4 book ai didi

java - maven-tomcat 插件部署在远程服务器上

转载 作者:行者123 更新时间:2023-11-28 22:42:01 24 4
gpt4 key购买 nike

我想在远程服务器上使用 maven 部署我的应用程序,以便拥有一个持续集成系统:)。

我在 stackoverflow 上检查了很多问题,但无法使其正常工作。首先我会告诉你我的错误,然后是我所做的配置。这里是关于上传的消息,它似乎是正确的: Uploaded: http://SERVEUR_IP/manager/text/deploy?path=%2FGiveMeAShow (49631 KB at 51.5 KB/sec)

错误:

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:deploy (default-cli) on project GiveMeAShow: Tomcat return http status error: 401, Reason Phrase: Unauthorized:
[ERROR] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
[ERROR] <html>
[ERROR] <head>
[ERROR] <title>401 Unauthorized</title>
[ERROR] <style type="text/css">
[ERROR] <!--
[ERROR] BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;font-size:12px;}
[ERROR] H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
[ERROR] PRE, TT {border: 1px dotted #525D76}
[ERROR] A {color : black;}A.name {color : black;}
[ERROR] -->
[ERROR] </style>
[ERROR] </head>
[ERROR] <body>
[ERROR] <h1>401 Unauthorized</h1>
[ERROR] <p>
[ERROR] You are not authorized to view this page. If you have not changed
[ERROR] any configuration files, please examine the file
[ERROR] <tt>conf/tomcat-users.xml</tt> in your installation. That
[ERROR] file must contain the credentials to let you use this webapp.
[ERROR] </p>
[ERROR] <p>
[ERROR] For example, to add the <tt>manager-gui</tt> role to a user named
[ERROR] <tt>tomcat</tt> with a password of <tt>s3cret</tt>, add the following to the
[ERROR] config file listed above.
[ERROR] </p>
[ERROR] <pre>
[ERROR] &lt;role rolename="manager-gui"/&gt;
[ERROR] &lt;user username="tomcat" password="s3cret" roles="manager-gui"/&gt;
[ERROR] </pre>
[ERROR] <p>
[ERROR] Note that for Tomcat 7 onwards, the roles required to use the manager
[ERROR] application were changed from the single <tt>manager</tt> role to the
[ERROR] following four roles. You will need to assign the role(s) required for
[ERROR] the functionality you wish to access.
[ERROR] </p>
[ERROR] <ul>
[ERROR] <li><tt>manager-gui</tt> - allows access to the HTML GUI and the status
[ERROR] pages</li>
[ERROR] <li><tt>manager-script</tt> - allows access to the text interface and the
[ERROR] status pages</li>
[ERROR] <li><tt>manager-jmx</tt> - allows access to the JMX proxy and the status
[ERROR] pages</li>
[ERROR] <li><tt>manager-status</tt> - allows access to the status pages only</li>
[ERROR] </ul>
[ERROR] <p>
[ERROR] The HTML interface is protected against CSRF but the text and JMX interfaces
[ERROR] are not. To maintain the CSRF protection:
[ERROR] </p>
[ERROR] <ul>
[ERROR] <li>Users with the <tt>manager-gui</tt> role should not be granted either
[ERROR] the <tt>manager-script</tt> or <tt>manager-jmx</tt> roles.</li>
[ERROR] <li>If the text or jmx interfaces are accessed through a browser (e.g. for
[ERROR] testing since these interfaces are intended for tools not humans) then
[ERROR] the browser must be closed afterwards to terminate the session.</li>
[ERROR] </ul>
[ERROR] <p>
[ERROR] For more information - please see the
[ERROR] <a href="/docs/manager-howto.html">Manager App HOW-TO</a>.
[ERROR] </p>
[ERROR] </body>
[ERROR]
[ERROR] </html>
[ERROR] -> [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

看起来很清楚,这是一个授权问题。让我们看看我的远程 tomcat7 tomcat-users.xml 文件:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<role rolename="manager-script"/>
<role rolename="admin-script"/>
<user username="admin" password="password" roles="manager-gui,manager-script,admin-gui,admin-script" />
</tomcat-users>

我知道我不应该授予所有角色,但是嘿它不起作用所以我正在尝试:)。

我可以在浏览器中使用“admin”和“password”通过 HTTP 登录应用程序管理器/管理页面。我认为这很好。

这是我在 maven-tomcat-plugin 中的配置:

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<usernamee>admin</usernamee>
<password>password</password>
<url>http:SERVEUR_IP/manager/text</url>
<server>TomcatServer</server>
<path>/GiveMeAShow</path>
</configuration>
</plugin>

当我开始尝试时,我无法上传 war 文件。添加这个允许我这样做。但是授权问题好像是后天的。

我还在 ~/.m2/settings.xml 的远程服务器中放置了一个 settings.xml 文件:

<?xml version='1.0' encoding='utf-8'?>
<servers>
<server>
<id>TomcatServer</id>
<username>admin</username>
<password>password</password>
</server>
</servers>

~/.m2文件夹只包含一个子文件夹和我创建的这个文件。

请注意,我正在使用 root 用户执行所有这些操作。

我现在不知道该试试什么,谢谢你的帮助!

编辑

我确实喜欢@fatteddy 说的:- 创建了一个仅限部署的用户。只有角色“经理脚本”- 更正了我在 pom.xml 中的错误,更改了 <usernamee></username>

我认为创建一个仅限部署的用户完成了大部分工作,因为我同时使用 <username> 中的环境变量在 TRAVIS-CI 上进行测试。标签编写无误。

最佳答案

实际上这是一个身份验证问题。尝试定义(显然出于安全原因)一个单独的部署用户,并分配了 manager-script (这是唯一的)角色。不要忘记重新启动 tomcat。

如果这不能帮助更改 tomcat 管理器 URL 的路径段(manager/managermanager/text 的组合, manager/text/ -> 据我所知,尾部斜杠存在/或存在问题,这些问题已在以后的 tomcat 版本中修复)

关于java - maven-tomcat 插件部署在远程服务器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28285211/

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