eclipse 将 Gradle 项目与工作区同步失败

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42354891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:22:41  来源:igfitidea点击:

Synchronize Gradle projects with workspace failed

javaeclipsespringgradle

提问by Andrea Bevilacqua

I've the Spring Tool Suite v3.8.3 and its component Spring IDE v3.8.4.201702201939-CI-B1500. I've also the Gradle Buildship v2.0.

我有 Spring Tool Suite v3.8.3 及其组件 Spring IDE v3.8.4.201702201939-CI-B1500。我还有 Gradle Buildship v2.0。

I created a project with JHipster v4.0.5 but is not possible to import it. (there were not errors before the Gradle Buildship 2). Below the error:

我使用 JHipster v4.0.5 创建了一个项目,但无法导入它。(在 Gradle Buildship 2 之前没有错误)。在错误下方:

Synchronize Gradle projects with workspace failed due to an unsupported configuration in the referenced Gradle build. Project at 'C:\ws\Testa' can't be named 'testa' because it's located directly under the workspace root. If such a project is renamed, Eclipse would move the container directory. To resolve this problem, move the project out of the workspace root or configure it to have the name 'Testa'.

由于引用的 Gradle 构建中的配置不受支持,将 Gradle 项目与工作区同步失败。位于“C:\ws\Testa”的项目不能命名为“testa”,因为它直接位于工作区根目录下。如果这样的项目被重命名,Eclipse 将移动容器目录。要解决此问题,请将项目移出工作区根目录或将其配置为具有名称“Testa”。

org.eclipse.buildship.core.UnsupportedConfigurationException: Project at 'C:\ws\Testa' can't be named 'testa' because it's located directly under the workspace root. If such a project is renamed, Eclipse would move the container directory. To resolve this problem, move the project out of the workspace root or configure it to have the name 'Testa'.
    at org.eclipse.buildship.core.workspace.internal.DefaultWorkspaceOperations.validateProjectName(DefaultWorkspaceOperations.java:190)
    at org.eclipse.buildship.core.workspace.internal.ProjectNameUpdater.checkProjectName(ProjectNameUpdater.java:107)
    at org.eclipse.buildship.core.workspace.internal.ProjectNameUpdater.ensureProjectNameIsFree(ProjectNameUpdater.java:71)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.addNewEclipseProjectToWorkspace(SynchronizeGradleBuildOperation.java:274)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeNonWorkspaceProject(SynchronizeGradleBuildOperation.java:258)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeGradleProjectWithWorkspaceProject(SynchronizeGradleBuildOperation.java:182)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.access
      rootProject.name='ToMyNewProjectName'
0(SynchronizeGradleBuildOperation.java:106) at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:141) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2262) at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.synchronizeProjectsWithWorkspace(SynchronizeGradleBuildOperation.java:138) at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation.run(SynchronizeGradleBuildOperation.java:122) at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.synchronizeBuild(SynchronizeGradleBuildsJob.java:77) at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildsJob.runToolingApiJob(SynchronizeGradleBuildsJob.java:68) at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:73) at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:62) at org.eclipse.buildship.core.util.progress.ToolingApiJob.run(ToolingApiJob.java:70) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Any help?

有什么帮助吗?

Thanks Regards, Andrea

谢谢问候, 安德里亚

回答by Darlesh

So I noticed that the "settings.gradle"file was setting the root project name, and after the project rename, it still had the old name. Once I changed that name to the new name and refreshed the project, that error went away.

所以我注意到“settings.gradle”文件正在设置根项目名称,并且在项目重命名后,它仍然是旧名称。一旦我将该名称更改为新名称并刷新项目,该错误就消失了。

回答by Atul Sharma

Have faced the same issue and sorted by updating 2 files in Project root.

遇到了同样的问题并通过更新项目根目录中的 2 个文件进行排序。

1) settings.gradle file ==>

1) settings.gradle 文件 ==>

         <ProjectDescription>
           <name> ToMyNewProjectName </name>
          </ProjectDescription>

2) .project file ==>

2) .project 文件 ==>

##代码##