使用Eclipse时,Tomcat 7会覆盖tomcat-users.xml [英] Tomcat 7 overrides the tomcat-users.xml when using Eclipse

查看:141
本文介绍了使用Eclipse时,Tomcat 7会覆盖tomcat-users.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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:


  • 变式1:将
    之前的Tomcat 7的tomcat-users.xml文件更改为,将其添加到Eclipse。这是因为我怀疑当我使用使用
    Tomcat安装选项时,Eclipse会将旧的tomcat-users.xml复制到其元数据文件夹
    中,当我更改Tomcat的安装目录后,不要在元数据中重写它。
    然后,由于某些原因,当通过Eclipse运行服务器I
    怀疑它检查文件是否相同,如果不是,
    将覆盖Tomcat的tomcat-users.xml安装文件夹。

  • 使用使用工作区元数据选项。这是默认值。然后去Eclipse的Package explorer - >你的Tomcat Server - > 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 into your-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中,转到Project Explorer面板中的项目服务器,并在文件夹Tomcat v7中。 0 server at 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆