问题描述
我是Gradle的新手,我正在尝试本教程
反正还有吗?
您应该使用gradle eclipse插件。将此添加到您的 build.gradle
文件:
应用插件: eclipse
这会将eclipse相关任务添加到您的构建中。通过执行
gradlew cleanEclipse Eclipse
Gradle将基于您项目的当前依赖项重新生成所有eclipse项目和类路径文件。但是,您将需要刷新IDE以使更改可见。
还需要考虑一件事。由于eclipse并不真正了解gradle依赖关系-它仅通过生成的classpath文件知道它们,因此只有重新生成这些依赖关系后,新的依赖关系才对Eclipse可见。此外,在eclipse中添加的依赖项对您的gradle构建将不可见,并且将在重新生成类路径文件后将其删除。
I am new to Gradle and I was trying this tutorial https://spring.io/guides/gs/rest-service/I was able to compile the jar with the required dependencies and run it.However, I find it annoying that the libraries are not recognized by the IDE.
Is there anyway to do it?
You should use the gradle eclipse plugin. Add this to your build.gradle
file:
apply plugin: "eclipse"
This will add eclipse related tasks to your build. By executing
gradlew cleanEclipse eclipse
Gradle will regenerate all eclipse project and classpath files based on the current dependencies of your project(s). You will however need to refresh your IDE to make the changes visible.
There is one more thing to consider. As eclipse is not really aware of the gradle dependencies - it knows them only by the generated classpath files - new dependencies will be visible to eclipse only after regenerating these files. Furthermore dependencies added in eclipse will not be visible to your gradle build and will be removed once the classpath files are regenerated.
这篇关于Eclipse无法识别Gradle依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!