问题描述
我是 Gradle 新手,我正在尝试本教程
还有办法吗?
你应该使用 gradle eclipse 插件.将此添加到您的 build.gradle
文件中:
应用插件:eclipse"
这会将与 Eclipse 相关的任务添加到您的构建中.通过执行
gradlew cleanEclipse eclipse
Gradle 将根据项目的当前依赖关系重新生成所有 eclipse 项目和类路径文件.但是,您需要刷新 IDE 以使更改可见.
还有一件事需要考虑.由于 eclipse 并没有真正意识到 gradle 依赖项——它只通过生成的类路径文件知道它们——新的依赖项只有在重新生成这些文件后才能对 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 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!