在 Eclipse 中更新我的 gradle 依赖项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17907927/
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
Update my gradle dependencies in eclipse
提问by Breako Breako
I have a simple gradle project in my eclipse. I update the build.gradle to include a few apache http jars...
我的 Eclipse 中有一个简单的 gradle 项目。我更新了 build.gradle 以包含一些 apache http jars...
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile 'org.apache.httpcomponents:httpclient:4.2.3'
compile "org.apache.httpcomponents:httpmime:4.2.3"
testCompile group: 'junit', name: 'junit', version: '4.+'
}
However in my code, where I reference some Apache HTTP stuff I get:
但是在我的代码中,我引用了一些 Apache HTTP 的内容:
The import org.apache.http cannot be resolved
Any tips on what I need to do to make Eclipse see the new dependencies in my build.gradle?
关于我需要做什么才能让 Eclipse 在我的 build.gradle 中看到新依赖项的任何提示?
I tried doing a clean but that does not work. My gradle plugin is:
我试过做一个干净的,但这不起作用。我的gradle插件是:
Gradle IDE 3.3.0.201307040643-RELEASE org.springsource.ide.eclipse.gradle.feature.feature.group GoPivotal, Inc.
回答by Peter Niederwieser
You have to select "Refresh Dependencies" in the "Gradle" context menu that appears when you right-click the project in the Package Explorer.
当您在 Package Explorer 中右键单击项目时,您必须在出现的“Gradle”上下文菜单中选择“Refresh Dependencies”。
回答by Kasun Kariyawasam
First, please check you have include eclipse gradle plugin. apply plugin : 'eclipse'
Then go to your project directory in Terminal. Type gradle clean
and then gradle eclipse
. Then go to project in eclipse and refresh the project.
首先,请检查您是否包含 eclipse gradle 插件。apply plugin : 'eclipse'
然后转到终端中的项目目录。键入gradle clean
然后gradle eclipse
。然后去eclipse中的project,刷新一下项目。
回答by Agustín
Looking at the Eclipse plugin docsI found some useful tasks that rebuilt my classpath and updated the required dependencies.
查看Eclipse 插件文档,我发现了一些有用的任务,它们重建了我的类路径并更新了所需的依赖项。
- First try
gradle cleanEclipse
to clean the Eclipse configuration completely. If this doesn;t work you may try more specific tasks:gradle cleanEclipseProject
to remove the .project filegradle cleanEclipseClasspath
to empty the project's classpath
- Finally
gradle eclipse
to rebuild the Eclipse configuration
- 首先尝试
gradle cleanEclipse
彻底清理 Eclipse 配置。如果这不起作用,您可以尝试更具体的任务:gradle cleanEclipseProject
删除 .project 文件gradle cleanEclipseClasspath
清空项目的类路径
- 最后
gradle eclipse
重建Eclipse配置
回答by yoram givon
You have to make sure that "Dependency Management" is enabled. To do so, right click on the project name, go to the "Gradle" sub-menu and click on "Enable Dependency Management". Once you do that, Gradle should load all the dependencies for you.
您必须确保启用了“依赖管理”。为此,右键单击项目名称,转到“Gradle”子菜单,然后单击“启用依赖项管理”。一旦你这样做了,Gradle 应该为你加载所有的依赖项。
回答by Sachin Thapa
I tried all above options but was still getting error, in my case issue was I have not setup gradle installation directory in eclipse, following worked:
我尝试了上述所有选项,但仍然出现错误,就我而言,问题是我没有在 eclipse 中设置 gradle 安装目录,以下工作:
eclipse -> Window -> Preferences -> Gradle -> "Select Local Installation Directory"
Click on Browse button and provide path.
eclipse -> Window -> Preferences -> Gradle -> “选择本地安装目录”
单击浏览按钮并提供路径。
Even though question is answered, thought to share in case somebody else is facing similar issue.
即使问题得到了回答,也想分享一下,以防其他人面临类似的问题。
Cheers !
干杯!