Java 如何为 NetBeans 设置 Tomcat 管理器应用程序用户名和密码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1321933/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 08:14:39  来源:igfitidea点击:

How do I set Tomcat Manager Application User Name and Password for NetBeans?

javajsptomcatnetbeans

提问by Eric Wilson

I'm trying to follow a tutorial to make an extremely basic Java web application in NetBeans.

我正在尝试按照教程在 NetBeans 中制作一个非常基本的 Java Web 应用程序。

When I try to run it, a dialogue box appears title "Authentication Required". Inside the dialogue box there the heading "Tomcat Manager Application" and fields for "User Name" and "Password."

当我尝试运行它时,会出现一个标题为“需要身份验证”的对话框。在对话框内有标题“Tomcat Manager Application”以及“用户名”和“密码”字段。

Investigating this, I've come to understand that I should edit the file

调查这个,我开始明白我应该编辑文件

\TOMCAT_HOME\conf\tomcat-users.xml

to include something like:

包括以下内容:

<user username="user" password="password" roles="standard,manager"/>

so I've done that, but it hasn't helped yet.

所以我已经这样做了,但还没有帮助。

Can anyone provide some insight? I'm using Tomcat 6.0.20, NetBeans 6.7.1, and Windows Vista. I'm using jdk1.7.0, but Java hasn't really entered into this project yet.

任何人都可以提供一些见解吗?我使用的是 Tomcat 6.0.20、NetBeans 6.7.1 和 Windows Vista。我用的是jdk1.7.0,但是Java还没有真正进入这个项目。

采纳答案by Eric Wilson

When you're launching tomcat server from netbeans IDE you need to check in menu "tools->servers" on connection tab for tomcat server - there is catalina base directory. And you need to include something like:

当您从 netbeans IDE 启动 tomcat 服务器时,您需要在 tomcat 服务器的连接选项卡上签入菜单“工具->服务器” - 有 catalina 基本目录。你需要包括以下内容:

 <role rolename="manager"/>
  <user username="admin" password="admin" roles="manager"/>

at file

在文件

\CATALINA_BASE\conf\tomcat-users.xml

or use username automatically generated by IDE with description already placed in this file or on connection tab

或使用 IDE 自动生成的用户名,描述已放置在此文件或连接选项卡上

For Manager Apps : GUI access:

对于管理器应用程序:GUI 访问

<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>

回答by Sheo

Netbeans Problem: For apache Tomcat server Authentication required dialog box requesting user name and password

Netbeans 问题:对于 apache Tomcat 服务器需要身份验证对话框请求用户名和密码

This dialog box appear If a user role and his credentials are not set or is incorrect for Tomcat startup via NetBeans IDE,

出现此对话框 如果用户角色及其凭据未设置或对于通过 NetBeans IDE 启动 Tomcat 不正确,

OR when user/pass set in IDE is not matches with user/pass in "canf/tomcat-user.xml" file

或者当 IDE 中设置的用户/密码与“canf/tomcat-user.xml”文件中的用户/密码不匹配时

1..Need to check user name and password set in IDE tools-->server

1..需要检查IDE工具-->服务器中设置的用户名和密码

2..Check \CATALINA_BASE\conf\tomcat-users.xml. whether user and his role is defined or not. If not add these lines

2..检查\CATALINA_BASE\conf\tomcat-users.xml。是否定义了用户及其角色。如果没有添加这些行

<user username="ide" password="EiWnNlBG" roles="manager-script,admin"/>
</tomcat-users>

3.. set the same user/pass in IDE tools->server

3..在IDE工具->服务器中设置相同的用户/密码

  1. restart your server to get effect of changes
  1. 重新启动您的服务器以获得更改的效果

Source: http://ohmjavaclasses.blogspot.com/2011/12/netbeans-problem-for-apache-tomcat.html

来源:http: //ohmjavaclasses.blogspot.com/2011/12/netbeans-problem-for-apache-tomcat.html

回答by Praveen Kumar

I case of tomcat 7 the role has changed from manager to manager-gui so set it as below in the tomcat-user.xml file.

在 tomcat 7 的情况下,角色已从 manager 更改为 manager-gui,因此在 tomcat-user.xml 文件中将其设置为如下所示。

enter image description here

在此处输入图片说明

回答by Drifeelgood9999

Follow my steps and be happy:

跟着我的脚步,开心就好:

1.- When you are configuring Netbeans for the first time, they will ask you for a "user" and "pass" for the Catalina-Server.

1.- 当您第一次配置 Netbeans 时,他们会要求您输入 Catalina-Server 的“用户”和“通行证”。

2.- Type whatever "user" and "pass" . This will modify your "tomcat-users.xml" and will add:

2.- 输入任何 "user" 和 "pass" 。这将修改您的“tomcat-users.xml”并添加:

user password="MYPASS" roles="manager-script,admin,tomcat" username="MYUSER"

用户密码=MYPASS角色=“manager-script,admin,tomcat”用户名=MYUSER

3.- To use this "user" just restartyour TOMCAT WEB SERVER and NETBEANS.

3.- 要使用此“用户”,只需重新启动您的 TOMCAT WEB SERVER 和 NETBEANS。

回答by Prazzy Kumar

Well if you are using Netbeans in Linux, then you should look for the tomcat-user.xmlin

那么如果你是在Linux中使用NetBeans,那么你应该寻找的tomcat-user.xml

/home/Username/.netbeans/8.0/apache-tomcat-8.0.3.0_base/conf

(its called Catalina Base and is often hidden) instead of the Apache installation directory.

(它被称为 Catalina Base 并且通常是隐藏的)而不是 Apache 安装目录。

open tomcat-user.xmlinside that folder, uncomment the user and roles and add/replace the following line.

打开该文件夹中的tomcat-user.xml,取消注释用户和角色并添加/替换以下行。

    <user username="tomcat" password="tomcat" roles="tomcat,admin,admin-gui,manager,manager-gui"/>

restart the server . That's all

重新启动服务器。就这样

回答by Do Nhu Vy

File \conf\tomcat-users.xml, before this line

文件\conf\tomcat-users.xml,在这一行之前

</tomcat-users>

add these lines

添加这些行

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>   
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status"/>

回答by DoesEatOats

One simple way to check your changes to that file in Tomcat 8 + is to open a browser to: http://localhost:8080/manager/text/list

在 Tomcat 8 + 中检查对该文件所做更改的一种简单方法是打开浏览器: http://localhost:8080/manager/text/list

回答by Usman Yaqoob

Go to apache-tomcat\conf folder add these lines in

转到 apache-tomcat\conf 文件夹中添加这些行

tomcat-users.xml file

tomcat-users.xml 文件

<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="manager-gui"/>

and restart server

并重启服务器

回答by JensD

You will find the tomcat-users.xml in \Users\<Name>\AppData\Roaming\Netbeans\. It exists at least twiceon your machine, depending on the number of Tomcat installations you have.

您将在 .xml 中找到 tomcat-users.xml \Users\<Name>\AppData\Roaming\Netbeans\。它在您的机器上至少存在两次,具体取决于您拥有的 Tomcat 安装数量。

回答by Bheem Singh

Update the 'apache-tomcat-8.5.5\conf\tomcat-users.xml file. uncomment the roles and add/replace the following line.and restart server

更新 'apache-tomcat-8.5.5\conf\tomcat-users.xml 文件。取消对角色的注释并添加/替换以下行。然后重新启动服务器

tomcat-users.xml file

tomcat-users.xml 文件

<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager-gui"/>
<user username="admin" password="admin" roles="standard,manager,admin,manager-gui,manager-script"/>