将Gradle项目与工作空间同步失败

时间:2017-02-20 21:52:15

标签: java eclipse spring gradle

我使用的是Spring Tool Suite v3.8.3及其组件Spring IDE v3.8.4.201702201939-CI-B1500。我也是Gradle Buildship v2.0。

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

由于引用的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$000(SynchronizeGradleBuildOperation.java:106)
    at org.eclipse.buildship.core.workspace.internal.SynchronizeGradleBuildOperation$1.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$1.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)

任何帮助?

由于 问候, 安德烈

3 个答案:

答案 0 :(得分:7)

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

答案 1 :(得分:1)

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

1)settings.gradle文件==>

      rootProject.name='ToMyNewProjectName'

2).project文件==>

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

答案 2 :(得分:0)

  1. 右键单击项目->属性->单击gradle下的“覆盖工作区设置”复选框
  2. 单击“本地安装目录”单选按钮->浏览并选择gradle安装的文件夹
  3. 在“ Gradle用户主目录”下->从用户中选择“ .gradle”文件夹

之后重建项目。