简体   繁体   English

Gradle 依赖项在 IntelliJ 中不起作用

[英]Gradle dependencies not working in IntelliJ

I'm working on an intelliJ project with my friends where we use MongoDB & Morphia.我正在和我的朋友一起从事一个使用 MongoDB 和 Morphia 的 intelliJ 项目。 We have the mongo stuff as a dependency in Gradle, as you can see here:我们在 Gradle 中有 mongo 的东西作为依赖,你可以在这里看到:

在此处输入图片说明

I didn't set this stuff up, I cloned it from a repository.我没有设置这些东西,我从存储库中克隆了它。 But my other friends have gotten this to work - all on Windows, OSX, and Linux.但是我的其他朋友已经让这个工作了——都在 Windows、OSX 和 Linux 上。 And only one of them set it up.只有其中一个设置了它。

The issue is that it doesn't know what Morphia / MongoDB is (for example, the imports don't work).问题是它不知道 Morphia / MongoDB 是什么(例如,导入不起作用)。

What I have done:我所做的:

  • Resync Gradle重新同步 Gradle
  • Run the Gradle.build file运行 Gradle.build 文件
  • Reclone the project重新克隆项目
  • Invalidate caching and restart使缓存无效并重新启动

And it still doesn't know what MongoDB is.它仍然不知道 MongoDB 是什么。 So then I tried to get everything working in a VM of Ubuntu, but I have a similar issue, except it doesn't list any of the dependencies you see above.然后我试图让一切在 Ubuntu 的 VM 中工作,但我有一个类似的问题,除了它没有列出你在上面看到的任何依赖项。

Anyone have any ideas on what I need to do on my end to get this working?任何人都对我需要做什么才能使这项工作有任何想法?

Here is the Build.gradle, minus the first line where we define the group (it contains my friend's name).这是 Build.gradle,减去我们定义组的第一行(它包含我朋友的名字)。

在此处输入图片说明

Possibly something to do with the issue: They complain that some of the dependecies are "invalid".可能与问题有关:他们抱怨某些依赖项是“无效的”。

在此处输入图片说明

在此处输入图片说明

There were invalid dependencies.存在无效的依赖项。 I removed those and it started to work.我删除了那些,它开始工作。

Not a solution, but a couple of things to try/verify (and also a little long for a comment)不是解决方案,而是要尝试/验证的几件事(并且评论也有点长)

  1. Does a java class that does not use any of the dependencies compile?不使用任何依赖项的 java 类是否可以编译?

  2. Does the gradle build work in a shell/console? gradle 构建是否在 shell/控制台中工作?

  3. Does IntelliJ actually pick up the changes to the build file. IntelliJ 是否真正获取了对构建文件的更改。 For example change the version of a dependency, hit the reload button in IntelliJ and check if the version gets updated.例如,更改依赖项的版本,点击 IntelliJ 中的重新加载按钮并检查版本是否更新。

  4. Check the project/module settings if the Dependencies are listed as expected如果依赖项按预期列出,请检查项目/模块设置

  5. Are you using everywhere the same version of Gradle?您是否到处都在使用相同版本的 Gradle? The use of the gradle wrapper is recommended.建议使用 gradle 包装器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM