显示 Maven 依赖项的 Eclipse 工作区不在构建路径中

Eclipse workspace showing maven dependencies are not in build path

我使用 Maven4MyEclipse 插件将 eclipse 项目转换为 maven,将项目结构转换为 maven 标准(src/main/java,等等),在 pom 中添加所有依赖项,编辑 maven 的用户设置这样依赖项就会从公司的存储库中下载。当我更新项目或下载源代码时,我的本地存储库中包含所有依赖项,但我仍然在编辑器中显示错误。 我也在项目目录下运行 mvn eclipse:eclipse 并且eclipse错误日志显示

eclipse.buildId=unknown java.version=1.7.0_45 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86

Error Thu Apr 07 14:00:09 CDT 2016 Unable to update index for art_central|http://maven/artifactory/libs-snapshot: C:\Software\Maven\repo.cache\m2e.4.032f6eda485b47ee5bbcc1113190690\nexus-maven-repository-index.zip (The system cannot find the file specified)

而且我还在错误日志中看到一个错误,指出它找不到文件并且正在查看旧的目录结构

org.eclipse.core.internal.resources.ResourceException: Resource '/Automation/src/main/dru/pageActions/ARHistory.java' does not exist.

实际路径应该是/Automation/src/main/java/dru/pageActions/ARHistory.java

如果你现在有一个有效的 maven 项目(即你可以在 MyEclipse 之外构建它,使用外部 maven 安装)然后尝试剥离它的 eclipse 文件和设置(在 MyEclipse 之外),然后将它作为 maven 导入项目到 MyEclipse 中。这应该将其全部设置为具有 maven 性质的 MyEclipse 项目。

项目源文件夹(如构建路径属性页面中所示)似乎未正确设置。此外,运行 mvn eclipse:eclipse 对于 MyEclipse 不是必需的,并且可能会导致问题。希望这一切都可以通过导入为 Maven 项目来解决。