Eclipse 无法将项目识别为 Gradle 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14751276/
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-10 21:33:05  来源:igfitidea点击:

Eclipse not recognizing project as Gradle Project

eclipsegradle

提问by Midhun M R

I want to build a project with gradle. I have included build.gradle in my project. But eclipse is not recognizing it as gradle project and I can't build it. Can anybody give a solution for this.

我想用 gradle 构建一个项目。我在我的项目中包含了 build.gradle。但是 eclipse 没有将它识别为 gradle 项目,我无法构建它。任何人都可以为此提供解决方案。

回答by Pytry

I just had this problem in Spring Tool Suite.

我刚刚在 Spring Tool Suite 中遇到了这个问题。

Here's what I did.

这就是我所做的。

  1. Right-click on project for context menu.
  2. Go to "Configure" near the bottom of menu (for me)
  3. Select sub-menu option of "Convert to Gradle project".
  4. Refresh project.
  1. 右键单击项目以获取上下文菜单。
  2. 转到菜单底部附近的“配置”(对我而言)
  3. 选择“转换为 Gradle 项目”的子菜单选项。
  4. 刷新项目。

The imported project's build.gradlethen appeared in the drop-down options of the Gradle view.

导入的项目build.gradle随后出现在 Gradle 视图的下拉选项中。

回答by nybon

If you are using the Buildship Eclipse pluginfor Gradle integration, you can try to add the following snippet into your build.gradle file:

如果您使用Buildship Eclipse 插件进行 Gradle 集成,您可以尝试将以下代码段添加到您的 build.gradle 文件中:

eclipse {
    project.natures 'org.eclipse.buildship.core.gradleprojectnature'
    .....
}

Then run "gradle eclipse" to re-generate Eclipse project files and refresh your project in Eclipse.

然后运行“gradle eclipse”重新生成 Eclipse 项目文件并在 Eclipse 中刷新您的项目。

回答by specialk1st

In Eclipse Neon you:

在 Eclipse Neon 中,您:

Right-click on your project --> Configure --> Add Gradle Nature.

Your project will automatically refresh and you will see all the dependencies being downloaded by Gradle.

您的项目将自动刷新,您将看到 Gradle 正在下载的所有依赖项。

回答by JB Nizet

Eclipse doesn't have native support for Gradle. There's an eclipse pluginavailable from SpringSource in order to support Gradle in Eclipse, but the easiest way is to generate the eclipse project from gradle, following the documentation.

Eclipse 没有对 Gradle 的原生支持。有一个Eclipse插件,以支持摇篮在Eclipse提供的SpringSource,但最简单的方法是从产生的gradle Eclipse项目,下面的文档

回答by Unspeakable Horror

I had a similar problem, to get eclipse to recognize the Gradle project I added the Gradle nature and then I had to click on Gradle->Refresh Allthen the Gradle icon appeared and all dependencies were resolved.

我有一个类似的问题,为了让 eclipse 识别 Gradle 项目,我添加了 Gradle 性质,然后我必须点击,Gradle->Refresh All然后 Gradle 图标出现,所有依赖项都得到解决。

Clicking on Enable Dependency Managementbefore refreshing resulted in "This operation is not enabled" and all the Gradle menu options getting greyed out.

Enable Dependency Management在刷新之前单击导致“此操作未启用”并且所有 Gradle 菜单选项都变灰。