简体   繁体   English

Eclipse 需要很长时间才能保存 web.xml

[英]Eclipse takes long time to save web.xml

Well, I'm using Eclipse to build a dynamic web project(in Mac OS X).好吧,我正在使用 Eclipse 来构建动态 web 项目(在 Mac OS X 中)。 But there is something confused for me.但我有些困惑。 When I start Eclipse and click the project explorer to expend the project folder, it takes long time to finish it.当我启动 Eclipse 并单击项目资源管理器展开项目文件夹时,需要很长时间才能完成它。 What's more, when I change the web.xml, it takes for at least 5 seconds to save it.更重要的是,当我更改web.xml时,至少需要5秒钟才能保存它。 I want to know why.我想知道为什么。 Should I change something in the preference?我应该改变偏好吗?


ps ps

I just found that.If I restart Eclipse and don't click the project explorer, it would be fine to modify and save the web.xml.刚发现。如果我重启Eclipse,不点击项目资源管理器,修改保存web.xml就可以了。 But if I click to open the folders in the project explorer, it will take a long time to say the changes in web.xml now.但是如果我在项目资源管理器中点击打开文件夹,现在要说web.xml中的变化需要很长时间。 So why?所以为什么?


ps again再次ps

Well, I just meet with this problem again.好吧,我又遇到了这个问题。 I'm using Ubuntu 11.04 with 4GB RAM.我正在使用具有 4GB RAM 的 Ubuntu 11.04。 There are some other project similar but with lots of files.还有一些其他类似的项目,但有很多文件。 But it doesn't happen when I edit their web.xml.但是当我编辑他们的 web.xml 时它不会发生。 I'm confused again now.我现在又糊涂了。

I just find out that it maybe be related to the xml validation with remote DTD.我只是发现它可能与远程 DTD 的 xml 验证有关。 If I close the net connection, everything will be ok.如果我关闭网络连接,一切都会好的。


Done!完毕!

I change xsi:schemaLocation's attr from " http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd " to " http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ". I change xsi:schemaLocation's attr from " http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd " to " http:/ /java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ”。

Eclipse can run slow due to various reasons. Eclipse 由于各种原因可能运行缓慢。

Large number of projects大量项目

If you have a large number of projects, Eclipse needs to process all of them when doing a clean build on all projects, when searching for references (types / resources), when validation needs to occur.如果您有大量项目,Eclipse 需要在对所有项目进行干净构建时,在搜索引用(类型/资源)时,在需要进行验证时处理所有这些项目。 You can use working sets to organize your projects, and hide the ones you're not using.您可以使用工作集来组织您的项目,并隐藏您不使用的项目。

Validations on projects项目验证

Eclipse has the concept of validators that can be put on projects. Eclipse 具有可以放在项目上的验证器的概念。 This can lead to a lot of processing (ex: validation of xml, xsd, jsps /....).这可能会导致大量处理(例如:验证 xml、xsd、jsps /....)。 Sometimes it can be usefull to disable certain validators that you don't really need.有时禁用某些您并不真正需要的验证器会很有用。

Memory Memory

Memory can be tweaked by supplying standard java memory parameters in the eclipse.ini file. Memory 可以通过在 Z6B7B655DD522FAA3A8A07 文件中提供标准 java memory 参数来调整。 If insufficient memory is allocated to Eclipse, it can lead up to a lot of garbage collection, causing it to slow down.如果 memory 分配给 Eclipse 不足,会导致大量垃圾回收,导致其速度变慢。

Plugins插件

Some third party plugins introduce builders / validators that get applied on projects, that cuold slow down eclipse.一些第三方插件引入了应用于项目的构建器/验证器,这可能会减慢 eclipse。

Make sure you use the lastest version of Eclipse, don't put too much projects in your workspace, and keep the third party plugins to a minimum.确保您使用的是最新版本的 Eclipse,不要在工作空间中放置过多的项目,并将第三方插件保持在最低限度。

For if someone misses it there seems to be a bug still in 2020 about this, the OP answered himself with the right solution因为如果有人错过了它,似乎在 2020 年仍然存在一个错误,OP 用正确的解决方案回答了自己

I change xsi:schemaLocation's attr from " http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd " to " http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ". I change xsi:schemaLocation's attr from " http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd " to " http:/ /java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ”。

change the xsi:schemaLocation in the web.xml file as follow.更改 web.xml 文件中的 xsi:schemaLocation 如下。

Open web.xml You will find it in打开 web.xml 你会发现它在

 2nd line of web.xml file: web-app xmlns:...

In that change the xsi:schemaLocation as在那个改变 xsi:schemaLocation 为

xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"

Now save it.现在保存它。 Do your work做你的工作

It is a bug in eclipse for more than 2 years, please vote up the issue, mybe they give some attention: https://bugs.eclipse.org/bugs/show_bug.cgi?id=534776这是 eclipse 中的一个错误超过 2 年,请投票赞成这个问题,我贝他们会给予一些关注: https://bugs.Z6B7B655DD22FAA3F10677C513477_bug6.cgi?id=show.org.

Open eclipse.ini in your eclipse installation folder increase in -Xms and -Xmx打开 eclipse.ini 在你的 eclipse 安装文件夹中增加 -Xms 和 -Xmx

for my self: -Xms1024m -Xmx4096m对于我自己:-Xms1024m -Xmx4096m

this worked for me这对我有用

For me it seemed a bit silly but when applying the change as mentioned in another thread this solved the issue with Eclipse locking up for me.对我来说,这似乎有点傻,但是当应用另一个线程中提到的更改时,这解决了 Eclipse 为我锁定的问题。 Just put a ';'只需放一个';' between the two urls (2021.05.09).在两个网址之间(2021.05.09)。

https://stackoverflow.com/a/46161667 https://stackoverflow.com/a/46161667

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM