有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法使用Tomcat管理器部署war文件

我无法使用Tomcat管理器部署war文件
My\Tomcat\conf\Tomcat用户。xml如下所示:

<!--
<role rolename="manager-gui"/>    
<user name="tomcat" password="admin" roles="admin-gui,standard,manager-gui"/>
-->

此外,还编辑了\Servers\Tomcat v7。localhost config\tomcat用户上的0服务器。xml到

<!--
<role rolename="manager-gui"/>    
<user name="tomcat" password="admin" roles="admin-gui,standard,manager-gui"/>
-->

尽管如此,它还是在以下错误中显示了作为http://localhost:8080/manager/html启动服务器并提供适当凭据的错误

401 Unauthorized

You are not authorized to view this page. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file must contain the credentials to let you use this webapp.

For example, to add the manager-gui role to a user named tomcat with a password of s3cret, add the following to the config file listed above.

我还尝试添加经理。xml到\Tomcat\conf,但没有任何效果

<Context privileged="true" antiResourceLocking="false"
         docBase="${catalina.home}/webapps/manager">
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         allow="127\.0\.0\.1" />
</Context>

注意:我正在重新启动服务器,http://localhost:8080/不工作


共 (2) 个答案

  1. # 1 楼答案

    <role><user>标记只是XML注释中的纯文本,由<! >包围。删除注释的开头和结尾

    <!     <<< BEGINNING OF COMMENT. Remove this line
    <role rolename="manager-gui"/>    
    <user name="tomcat" password="admin" roles="admin-gui,standard,manager-gui"/>
     >     <<< END OF COMMENT.       Remove this line
    
  2. # 2 楼答案

    您需要在tomcat-users.xml中取消注释用户条目

    您需要将用户添加到/tomcat-users.xml,否则无法通过manager应用部署war文件

    例如:

    <user username="craigmcc" password="secret" roles="standard,manager-script" />
    

    更多configuration details are here