Eclipse 无法识别 Gradle 依赖项

Eclipse not recognizing Gradle dependencies(Eclipse 无法识别 Gradle 依赖项)
本文介绍了Eclipse 无法识别 Gradle 依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 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 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How can create a producer using Spring Cloud Kafka Stream 3.1(如何使用Spring Cloud Kafka Stream 3.1创建制片人)
Insert a position in a linked list Java(在链接列表中插入位置Java)
Did I write this constructor properly?(我是否正确地编写了这个构造函数?)
Head value set to null but tail value still gets displayed(Head值设置为空,但仍显示Tail值)
printing nodes from a singly-linked list(打印单链接列表中的节点)
Control namespace prefixes in web services?(控制Web服务中的命名空间前缀?)