Eclipse 在大型 Maven 项目中挂起 "verifying launch attributes"
Eclipse hangs on "verifying launch attributes" in large Maven projects
我正在使用 Eclipse 开发一个大型 Maven 项目(数十个依赖项)。当我尝试运行单元测试时,我看到大约一分钟的暂停,同时状态显示 "verifying launch attributes"。在 Process Monitor 中观察 Eclipse 的活动,我看到很多文件访问 Maven 存储库中的各种锁和 jar。看起来 Eclipse 遍历了我的项目所依赖的每个 JAR。一旦文件访问完成,实际测试就会开始。
我知道“Why is Eclipse hanging at 57% with the status “Verifying launch attributes…” when launching a run configuration?”中提供的建议,并且我遵循了建议的修正。我认为 Eclipse 正在通过遍历每个 JAR 来完成它应该做的事情。我的问题是,如何在 Eclipse 或 Maven 中禁用该行为?
我在 Windows 7 上使用 Eclipse Luna,m2e 版本 1.5.0.20140606
编辑:
下面是我在 Process Monitor 中看到的示例:
简而言之,我们花了大约 10 秒在合理的 activity 上,例如检查 Java 和 JAR 文件的状态,然后我们花了大约 40 秒锁定 Maven 存储库和读取 POM 文件.
eclipse 为什么要这样做?我需要改变什么来阻止它?
11:31:48.1468054 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\org\drools\drools-core.0.1.Final\drools-core-6.0.1.Final.jar SUCCESS Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:48.1469017 AM eclipse.exe 3736 QueryBasicInformationFile C:\LAS\Maven\Repository\org\drools\drools-core.0.1.Final\drools-core-6.0.1.Final.jar SUCCESS CreationTime: 7/21/2014 11:13:15 AM, LastAccessTime: 7/21/2014 11:13:15 AM, LastWriteTime: 7/21/2014 11:13:22 AM, ChangeTime: 7/21/2014 11:13:23 AM, FileAttributes: A
11:31:48.1469769 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\org\drools\drools-core.0.1.Final\drools-core-6.0.1.Final.jar SUCCESS
11:31:50.0040011 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\xpp3\xpp3_min.1.4c\xpp3_min-1.1.4c.jar SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:50.0040832 AM eclipse.exe 3736 QueryNetworkOpenInformationFile C:\LAS\Maven\Repository\xpp3\xpp3_min.1.4c\xpp3_min-1.1.4c.jar SUCCESS CreationTime: 7/21/2014 11:13:15 AM, LastAccessTime: 7/21/2014 11:13:15 AM, LastWriteTime: 7/21/2014 11:13:21 AM, ChangeTime: 7/21/2014 11:13:23 AM, AllocationSize: 28672, EndOfFile: 24956, FileAttributes: A
11:31:50.0041397 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\xpp3\xpp3_min.1.4c\xpp3_min-1.1.4c.jar SUCCESS
(相当于四秒)
11:31:50.0700821 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\.locks\com.lmax~disruptor~3.3.0.aetherlock SUCCESS Desired Access: Write Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:50.0701770 AM eclipse.exe 3736 SetBasicInformationFile C:\LAS\Maven\Repository\.locks\com.lmax~disruptor~3.3.0.aetherlock SUCCESS CreationTime: 0, LastAccessTime: 0, LastWriteTime: 0, ChangeTime: 0, FileAttributes: N
11:31:50.0703100 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\.locks\com.lmax~disruptor~3.3.0.aetherlock SUCCESS
11:31:59.7990517 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\.locks\xpp3~xpp3_min~1.1.4c.aetherlock SUCCESS Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:59.7991381 AM eclipse.exe 3736 QueryAttributeTagFile C:\LAS\Maven\Repository\.locks\xpp3~xpp3_min~1.1.4c.aetherlock SUCCESS Attributes: N, ReparseTag: 0x0
11:31:59.7991864 AM eclipse.exe 3736 SetDispositionInformationFile C:\LAS\Maven\Repository\.locks\xpp3~xpp3_min~1.1.4c.aetherlock SUCCESS Delete: True
11:31:59.7992609 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\.locks\xpp3~xpp3_min~1.1.4c.aetherlock SUCCESS
(9 秒的价值)
11:31:59.8364794 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\com\lmax\disruptor.3.0\disruptor-3.3.0-sources.jar SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:59.8367613 AM eclipse.exe 3736 QueryNetworkOpenInformationFile C:\LAS\Maven\Repository\com\lmax\disruptor.3.0\disruptor-3.3.0-sources.jar SUCCESS CreationTime: 11/18/2014 2:17:33 PM, LastAccessTime: 11/18/2014 2:17:33 PM, LastWriteTime: 11/18/2014 2:17:33 PM, ChangeTime: 11/18/2014 2:17:33 PM, AllocationSize: 81920, EndOfFile: 80291, FileAttributes: A
11:31:59.8367994 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\com\lmax\disruptor.3.0\disruptor-3.3.0-sources.jar SUCCESS
11:32:02.0222874 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\org\antlr\antlr-runtime.5\antlr-runtime-3.5.jar SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:32:02.0223541 AM eclipse.exe 3736 QueryNetworkOpenInformationFile C:\LAS\Maven\Repository\org\antlr\antlr-runtime.5\antlr-runtime-3.5.jar SUCCESS CreationTime: 7/21/2014 11:13:15 AM, LastAccessTime: 7/21/2014 11:13:15 AM, LastWriteTime: 7/21/2014 11:13:21 AM, ChangeTime: 7/21/2014 11:13:22 AM, AllocationSize: 167936, EndOfFile: 167735, FileAttributes: A
11:32:02.0223896 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\org\antlr\antlr-runtime.5\antlr-runtime-3.5.jar SUCCESS
(相当于 3 秒)
11:32:33.2963547 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\.locks\commons-logging~commons-logging~1.1.aetherlock SUCCESS Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:32:33.2964727 AM eclipse.exe 3736 QueryAttributeTagFile C:\LAS\Maven\Repository\.locks\commons-logging~commons-logging~1.1.aetherlock SUCCESS Attributes: N, ReparseTag: 0x0
11:32:33.2965390 AM eclipse.exe 3736 SetDispositionInformationFile C:\LAS\Maven\Repository\.locks\commons-logging~commons-logging~1.1.aetherlock SUCCESS Delete: True
11:32:33.2966382 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\.locks\commons-logging~commons-logging~1.1.aetherlock SUCCESS
11:32:33.2970685 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Desired Access: Synchronize, Disposition: Open, Options: , Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:32:33.2971806 AM eclipse.exe 3736 QueryNameInformationFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Name: \LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom
11:32:33.2972430 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS
11:32:33.2980275 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened
11:32:33.2981528 AM eclipse.exe 3736 ReadFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Offset: 0, Length: 4,096, Priority: Normal
11:32:33.2983145 AM eclipse.exe 3736 QueryStandardInformationFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS AllocationSize: 8,192, EndOfFile: 6,182, NumberOfLinks: 1, DeletePending: False, Directory: False
11:32:33.2983774 AM eclipse.exe 3736 ReadFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Offset: 4,096, Length: 2,086
11:32:33.2984420 AM eclipse.exe 3736 QueryStandardInformationFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS AllocationSize: 8,192, EndOfFile: 6,182, NumberOfLinks: 1, DeletePending: False, Directory: False
11:32:33.2985057 AM eclipse.exe 3736 QueryStandardInformationFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS AllocationSize: 8,192, EndOfFile: 6,182, NumberOfLinks: 1, DeletePending: False, Directory: False
11:32:33.2987730 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS
(30 秒!)
我不认为过多的锁 creation/access 是问题的根源。我的系统日志中也有数千行这样的行,以及 100 多个 Maven 依赖项,但一切都很快。
尝试 运行 Eclipse.To 之外的测试,转到 .pom 目录并键入
mvn test
如果再次一切都很慢,那么 eclipse 不是问题的根源,可能是它在 HDD 上的坏扇区或者谁知道是什么。
但是,如果速度很快,那么 Eclipse 确实是问题所在。
您可以尝试通过转到“首选项”>“验证”然后单击“暂停所有验证器”来全局关闭验证,并确保您的项目不会覆盖全局验证设置。
来自聊天:
mvn test spends ~ 20 seconds downloading maven-metadata.xml for our own packages from our own snapshot repository - something I don't see Eclipse doing. There is no large delay before mvn test starts showing output.
Closing all projects except the one you need brings build time down to 5s
the POM is configured to check every build for changes in snapshot, so the download happens every time
Eclipse的m2e插件使用了与Maven相同的策略。如果您告诉 Maven 检查每个构建的快照,那么 Eclipse 也会这样做。如果 mvn test
花费 20 秒检查依赖项,Eclipse 将需要相同的时间(您应该能够在 Eclipse 的 Maven 控制台中看到它;您可以在与 Stack Trace Console 相同的下拉菜单中找到此控制台 -在控制台视图的右上角寻找带有小 +
的按钮)
减少构建时间的建议:
- 更改 POM 的配置以每天仅检查一次快照。白天使用
mvn -U
升级它们。我觉得这个改动会带来最大的收获。
- 使用 CI 服务器使用最新快照构建所有内容,这样您就不必浪费时间
- 将所有快照依赖项拉入单个 Maven 项目;如果快照依赖项不是当前构建的一部分,Maven 只会下载它们。
- 升级您的网络并尝试调整您的 Maven 代理服务器(您从中下载快照)。我的经验是,这一步很昂贵,而且收益不大。
- 关闭尽可能多的项目。这通常会使 Eclipse 更快,但显然对快照检查没有帮助。
- 避免快照;与已发布的版本一起工作。想出一个快速发布流程,这样您就可以在需要时每天进行多次发布。
[编辑] 读取一个 XML 文件不需要 2 秒,除非你没有足够的内存。请检查这个(在首选项中使用 "General / Heap status")。
如果它仍然很慢,那么 m2e 会在 "Read Maven project" 这一步做一些事情。我的猜测是它重新计算类路径。如果这需要很长时间,则可以:
- 您的设置出现问题(-> 新工作区应该可以解决此问题)
- 您的本地 Maven 存储库已损坏。尝试删除
$HOME/.m2/repository/
- 如果您 "always update" 启用,请禁用它。如果它现在很快,那么你的网络或公司 Maven 存储库很慢。您将不得不再次禁用 "always update",忍受缓慢或与您的管理员交谈。
- 尝试禁用所有不需要的插件。您可能必须为此安装第二个 Eclipse。也许其他插件之一会导致延迟。我在 eGit 插件中看到过这种情况,它有时会进入无限循环以尝试刷新工作区状态。
- Windows:不要在用户的主文件夹或 Windows 索引的任何文件夹中创建工作区。
如果关闭项目有帮助,那么您可能需要关闭尽可能多的项目。
到目前为止,唯一有帮助的是关闭我工作区中的许多项目。当我的工作区有 30 个 Maven 依赖项时,单元测试需要 30 多秒才能开始。当我关闭这些项目并强制 Eclipse 转到本地存储库时,单元测试的开始需要 5 秒。
我发现开始时间和 "external" 依赖关系之间没有关联。只有 "internal"(在工作区和打开中)依赖关系很重要。
如果可以,您会尝试将 m2e 1.4.x 与较旧的 Eclipse 版本一起使用吗?根据我从 m2e 用户邮件列表 (http://dev.eclipse.org/mhonarc/lists/m2e-users/msg05095.html) 上的一位 m2e 开发人员那里得到的回复,在 m2e 1.5 上引入了项目缓存大小的限制。当我们将 m2e 从 1.4 升级到 1.6(使用 Eclipse 版本)时,我们开始看到像您这样的问题。我想看看您的问题是否可以用 m2e 1.4.x 重现。谢谢,塔米
出于这个原因,我关闭了一个 maven 存储库,导致 m2e 挂起。
我只是在我的 /etc/hosts 中禁用主机并且它有效。
我正在使用 Eclipse 开发一个大型 Maven 项目(数十个依赖项)。当我尝试运行单元测试时,我看到大约一分钟的暂停,同时状态显示 "verifying launch attributes"。在 Process Monitor 中观察 Eclipse 的活动,我看到很多文件访问 Maven 存储库中的各种锁和 jar。看起来 Eclipse 遍历了我的项目所依赖的每个 JAR。一旦文件访问完成,实际测试就会开始。
我知道“Why is Eclipse hanging at 57% with the status “Verifying launch attributes…” when launching a run configuration?”中提供的建议,并且我遵循了建议的修正。我认为 Eclipse 正在通过遍历每个 JAR 来完成它应该做的事情。我的问题是,如何在 Eclipse 或 Maven 中禁用该行为?
我在 Windows 7 上使用 Eclipse Luna,m2e 版本 1.5.0.20140606
编辑:
下面是我在 Process Monitor 中看到的示例:
简而言之,我们花了大约 10 秒在合理的 activity 上,例如检查 Java 和 JAR 文件的状态,然后我们花了大约 40 秒锁定 Maven 存储库和读取 POM 文件.
eclipse 为什么要这样做?我需要改变什么来阻止它?
11:31:48.1468054 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\org\drools\drools-core.0.1.Final\drools-core-6.0.1.Final.jar SUCCESS Desired Access: Read Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:48.1469017 AM eclipse.exe 3736 QueryBasicInformationFile C:\LAS\Maven\Repository\org\drools\drools-core.0.1.Final\drools-core-6.0.1.Final.jar SUCCESS CreationTime: 7/21/2014 11:13:15 AM, LastAccessTime: 7/21/2014 11:13:15 AM, LastWriteTime: 7/21/2014 11:13:22 AM, ChangeTime: 7/21/2014 11:13:23 AM, FileAttributes: A
11:31:48.1469769 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\org\drools\drools-core.0.1.Final\drools-core-6.0.1.Final.jar SUCCESS
11:31:50.0040011 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\xpp3\xpp3_min.1.4c\xpp3_min-1.1.4c.jar SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:50.0040832 AM eclipse.exe 3736 QueryNetworkOpenInformationFile C:\LAS\Maven\Repository\xpp3\xpp3_min.1.4c\xpp3_min-1.1.4c.jar SUCCESS CreationTime: 7/21/2014 11:13:15 AM, LastAccessTime: 7/21/2014 11:13:15 AM, LastWriteTime: 7/21/2014 11:13:21 AM, ChangeTime: 7/21/2014 11:13:23 AM, AllocationSize: 28672, EndOfFile: 24956, FileAttributes: A
11:31:50.0041397 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\xpp3\xpp3_min.1.4c\xpp3_min-1.1.4c.jar SUCCESS
(相当于四秒)
11:31:50.0700821 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\.locks\com.lmax~disruptor~3.3.0.aetherlock SUCCESS Desired Access: Write Attributes, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:50.0701770 AM eclipse.exe 3736 SetBasicInformationFile C:\LAS\Maven\Repository\.locks\com.lmax~disruptor~3.3.0.aetherlock SUCCESS CreationTime: 0, LastAccessTime: 0, LastWriteTime: 0, ChangeTime: 0, FileAttributes: N
11:31:50.0703100 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\.locks\com.lmax~disruptor~3.3.0.aetherlock SUCCESS
11:31:59.7990517 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\.locks\xpp3~xpp3_min~1.1.4c.aetherlock SUCCESS Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:59.7991381 AM eclipse.exe 3736 QueryAttributeTagFile C:\LAS\Maven\Repository\.locks\xpp3~xpp3_min~1.1.4c.aetherlock SUCCESS Attributes: N, ReparseTag: 0x0
11:31:59.7991864 AM eclipse.exe 3736 SetDispositionInformationFile C:\LAS\Maven\Repository\.locks\xpp3~xpp3_min~1.1.4c.aetherlock SUCCESS Delete: True
11:31:59.7992609 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\.locks\xpp3~xpp3_min~1.1.4c.aetherlock SUCCESS
(9 秒的价值)
11:31:59.8364794 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\com\lmax\disruptor.3.0\disruptor-3.3.0-sources.jar SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:31:59.8367613 AM eclipse.exe 3736 QueryNetworkOpenInformationFile C:\LAS\Maven\Repository\com\lmax\disruptor.3.0\disruptor-3.3.0-sources.jar SUCCESS CreationTime: 11/18/2014 2:17:33 PM, LastAccessTime: 11/18/2014 2:17:33 PM, LastWriteTime: 11/18/2014 2:17:33 PM, ChangeTime: 11/18/2014 2:17:33 PM, AllocationSize: 81920, EndOfFile: 80291, FileAttributes: A
11:31:59.8367994 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\com\lmax\disruptor.3.0\disruptor-3.3.0-sources.jar SUCCESS
11:32:02.0222874 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\org\antlr\antlr-runtime.5\antlr-runtime-3.5.jar SUCCESS Desired Access: Read Attributes, Disposition: Open, Options: Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:32:02.0223541 AM eclipse.exe 3736 QueryNetworkOpenInformationFile C:\LAS\Maven\Repository\org\antlr\antlr-runtime.5\antlr-runtime-3.5.jar SUCCESS CreationTime: 7/21/2014 11:13:15 AM, LastAccessTime: 7/21/2014 11:13:15 AM, LastWriteTime: 7/21/2014 11:13:21 AM, ChangeTime: 7/21/2014 11:13:22 AM, AllocationSize: 167936, EndOfFile: 167735, FileAttributes: A
11:32:02.0223896 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\org\antlr\antlr-runtime.5\antlr-runtime-3.5.jar SUCCESS
(相当于 3 秒)
11:32:33.2963547 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\.locks\commons-logging~commons-logging~1.1.aetherlock SUCCESS Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:32:33.2964727 AM eclipse.exe 3736 QueryAttributeTagFile C:\LAS\Maven\Repository\.locks\commons-logging~commons-logging~1.1.aetherlock SUCCESS Attributes: N, ReparseTag: 0x0
11:32:33.2965390 AM eclipse.exe 3736 SetDispositionInformationFile C:\LAS\Maven\Repository\.locks\commons-logging~commons-logging~1.1.aetherlock SUCCESS Delete: True
11:32:33.2966382 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\.locks\commons-logging~commons-logging~1.1.aetherlock SUCCESS
11:32:33.2970685 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Desired Access: Synchronize, Disposition: Open, Options: , Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
11:32:33.2971806 AM eclipse.exe 3736 QueryNameInformationFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Name: \LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom
11:32:33.2972430 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS
11:32:33.2980275 AM eclipse.exe 3736 CreateFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Desired Access: Generic Read, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: n/a, OpenResult: Opened
11:32:33.2981528 AM eclipse.exe 3736 ReadFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Offset: 0, Length: 4,096, Priority: Normal
11:32:33.2983145 AM eclipse.exe 3736 QueryStandardInformationFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS AllocationSize: 8,192, EndOfFile: 6,182, NumberOfLinks: 1, DeletePending: False, Directory: False
11:32:33.2983774 AM eclipse.exe 3736 ReadFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS Offset: 4,096, Length: 2,086
11:32:33.2984420 AM eclipse.exe 3736 QueryStandardInformationFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS AllocationSize: 8,192, EndOfFile: 6,182, NumberOfLinks: 1, DeletePending: False, Directory: False
11:32:33.2985057 AM eclipse.exe 3736 QueryStandardInformationFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS AllocationSize: 8,192, EndOfFile: 6,182, NumberOfLinks: 1, DeletePending: False, Directory: False
11:32:33.2987730 AM eclipse.exe 3736 CloseFile C:\LAS\Maven\Repository\commons-logging\commons-logging.1\commons-logging-1.1.pom SUCCESS
(30 秒!)
我不认为过多的锁 creation/access 是问题的根源。我的系统日志中也有数千行这样的行,以及 100 多个 Maven 依赖项,但一切都很快。
尝试 运行 Eclipse.To 之外的测试,转到 .pom 目录并键入
mvn test
如果再次一切都很慢,那么 eclipse 不是问题的根源,可能是它在 HDD 上的坏扇区或者谁知道是什么。
但是,如果速度很快,那么 Eclipse 确实是问题所在。
您可以尝试通过转到“首选项”>“验证”然后单击“暂停所有验证器”来全局关闭验证,并确保您的项目不会覆盖全局验证设置。
来自聊天:
mvn test spends ~ 20 seconds downloading maven-metadata.xml for our own packages from our own snapshot repository - something I don't see Eclipse doing. There is no large delay before mvn test starts showing output.
Closing all projects except the one you need brings build time down to 5s the POM is configured to check every build for changes in snapshot, so the download happens every time
Eclipse的m2e插件使用了与Maven相同的策略。如果您告诉 Maven 检查每个构建的快照,那么 Eclipse 也会这样做。如果 mvn test
花费 20 秒检查依赖项,Eclipse 将需要相同的时间(您应该能够在 Eclipse 的 Maven 控制台中看到它;您可以在与 Stack Trace Console 相同的下拉菜单中找到此控制台 -在控制台视图的右上角寻找带有小 +
的按钮)
减少构建时间的建议:
- 更改 POM 的配置以每天仅检查一次快照。白天使用
mvn -U
升级它们。我觉得这个改动会带来最大的收获。 - 使用 CI 服务器使用最新快照构建所有内容,这样您就不必浪费时间
- 将所有快照依赖项拉入单个 Maven 项目;如果快照依赖项不是当前构建的一部分,Maven 只会下载它们。
- 升级您的网络并尝试调整您的 Maven 代理服务器(您从中下载快照)。我的经验是,这一步很昂贵,而且收益不大。
- 关闭尽可能多的项目。这通常会使 Eclipse 更快,但显然对快照检查没有帮助。
- 避免快照;与已发布的版本一起工作。想出一个快速发布流程,这样您就可以在需要时每天进行多次发布。
[编辑] 读取一个 XML 文件不需要 2 秒,除非你没有足够的内存。请检查这个(在首选项中使用 "General / Heap status")。
如果它仍然很慢,那么 m2e 会在 "Read Maven project" 这一步做一些事情。我的猜测是它重新计算类路径。如果这需要很长时间,则可以:
- 您的设置出现问题(-> 新工作区应该可以解决此问题)
- 您的本地 Maven 存储库已损坏。尝试删除
$HOME/.m2/repository/
- 如果您 "always update" 启用,请禁用它。如果它现在很快,那么你的网络或公司 Maven 存储库很慢。您将不得不再次禁用 "always update",忍受缓慢或与您的管理员交谈。
- 尝试禁用所有不需要的插件。您可能必须为此安装第二个 Eclipse。也许其他插件之一会导致延迟。我在 eGit 插件中看到过这种情况,它有时会进入无限循环以尝试刷新工作区状态。
- Windows:不要在用户的主文件夹或 Windows 索引的任何文件夹中创建工作区。
如果关闭项目有帮助,那么您可能需要关闭尽可能多的项目。
到目前为止,唯一有帮助的是关闭我工作区中的许多项目。当我的工作区有 30 个 Maven 依赖项时,单元测试需要 30 多秒才能开始。当我关闭这些项目并强制 Eclipse 转到本地存储库时,单元测试的开始需要 5 秒。
我发现开始时间和 "external" 依赖关系之间没有关联。只有 "internal"(在工作区和打开中)依赖关系很重要。
如果可以,您会尝试将 m2e 1.4.x 与较旧的 Eclipse 版本一起使用吗?根据我从 m2e 用户邮件列表 (http://dev.eclipse.org/mhonarc/lists/m2e-users/msg05095.html) 上的一位 m2e 开发人员那里得到的回复,在 m2e 1.5 上引入了项目缓存大小的限制。当我们将 m2e 从 1.4 升级到 1.6(使用 Eclipse 版本)时,我们开始看到像您这样的问题。我想看看您的问题是否可以用 m2e 1.4.x 重现。谢谢,塔米
出于这个原因,我关闭了一个 maven 存储库,导致 m2e 挂起。 我只是在我的 /etc/hosts 中禁用主机并且它有效。