当使用Eclipse时,Tomcat 7覆盖tomcat-users.xml [英] Tomcat 7 overrides the tomcat-users.xml when using Eclipse
问题描述
我使用 Tomcat 7
部署我的web项目。当我使用 Eclipse接口
启动和停止我的Tomcat时,我更舒服,所以我把它添加到 Eclipse的服务器
并检查服务器位置中的使用Tomcat安装。我使用的另一件事是
Tomcat的web管理器工具
来部署/取消部署项目。
我们知道为了使用Manager / html工具,你必须登录。认证的用户名和密码在tomcat-users.xml中设置,像这样(在我的文件中):
I am using Tomcat 7
to deploy my web projects on. Also I am more comfortable when using the Eclipse interface
to start and stop my Tomcat, so I've added it in the Eclipse's Servers
and check the "Use Tomcat Installation" in Server Locations
. One more thing that I use is the Tomcat's web Manager tool
to deploy/undeploy the projects.
As we know in order to use the Manager/html tool you have to sign in. The username and the password to authenticate are set in the tomcat-users.xml like this (in my file):
<role rolename="tomcat"/>
<role rolename="manager"/>
<role rolename="manager-script"/>
<role rolename="manager-gui"/>
<role rolename="standard"/>
<role rolename="admin"/>
<user username="tomcat-eclipse" password="tomcat-eclipse" roles="tomcat,manager,manager-script,standard,admin"/>
<user username="root" password="toor" roles="manager-gui" />
一切正常,直到某个时刻(我不知道,但可能在几次重新启动或重新部署)我输入的配置被刷新,默认(空配置)文件覆盖我自定义的配置。
Everything works fine until some moment in time (I'm not sure but maybe after several restarts or redeploys) the configuration that I've entered is flushed and the default (empty configuration) file overrides my customized config.
问:导致文件被覆盖的原因是什么?如何防止?非常感谢。
Q: What causes the file to be overridden and how can I prevent that? Thanks.
编辑:
A:我根据一些实验建议:
A: What I suggest based on some experiments is:
- 变体一:更改Tomcat 7的tomcat-users.xml文件之前
,将其添加到Eclipse。这是因为我怀疑当我使用使用
Tomcat安装选项Eclipse复制旧的tomcat-users.xml在其元数据文件夹
,当我更改它以后在Tomcat的安装目录,它don不会在元数据中覆盖它。
然后,由于某种原因,当通过Eclipse运行服务器时I
怀疑它检查文件是否相同,如果不一致,那么
会覆盖Tomcat中的tomcat-users.xml - 使用使用工作区元数据选项。它是默认值。然后转到Eclipse的Package explorer - >您的Tomcat服务器 - > tomcat-users.xml并从那里更改它。您还可以将
your-tomcat-install-dir / webapps
的内容复制到your-eclipse-workspace / .metadata / .plugins / org。 eclipse.wst.server.core / tmp0 / wtpwebapps /
以便拥有不错的Tomcat html界面(如教程:安装Tomcat 7并在Eclipse中使用它)。
- Variant one: Change the Tomcat 7's tomcat-users.xml file before you add it to Eclipse. This is because I suspect when I was using the "Use Tomcat Installation" option Eclipse copied the old tomcat-users.xml in its metadata folder and when I change it later in Tomcat's install dir, it don't overrides it in the metadata. Then, for some reason, when running the server through Eclipse I suspect that it checks if the files are the same and if not then it overrides the tomcat-users.xml in the Tomcat's installation folder.
- Use "Use workspace metadata" option. It is default. Then go to the Eclipse's Package explorer -> Your Tomcat Server -> tomcat-users.xml and change it from there. You can also copy the contents of
your-tomcat-install-dir/webapps
intoyour-eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/
in order to have the nice Tomcat html interface (as shown in Tutorial: Installing Tomcat 7 and Using it with Eclipse).
尝试。 :)
推荐答案
在Eclipse中,在项目资源管理器面板和Tomcat v7文件夹中, 0服务器在localhost-config'(这是一个Tomcat服务器的默认名称,也许你的略有不同)更改那里tomcat-users.xml
In Eclipse go to your Project 'Servers' in your 'Project Explorer' panel and inside folder 'Tomcat v7.0 Server at localhost-config'(this is the default name for a Tomcat server maybe yours is slightly different) change there tomcat-users.xml
项目浏览器>'服务器'> Tomcat v7.0服务器在localhost-config> tomcat-users.xml
Project Explorer > 'Server's > Tomcat v7.0 Server at localhost-config > tomcat-users.xml
这篇关于当使用Eclipse时,Tomcat 7覆盖tomcat-users.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!