Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Dependencies not recognized in Intellij

I'm working on a Spring Boot Application using Gradle as a dependency management system or whatever.

After adding a couple of dependencies to the build script and rebuilding the project, I would expect the build to have added those dependencies to the project. And yet, it does not. Cannot import those libraries. What step am I missing?? I am a node.js developer and am used to just running an npm install to import dependencies.

Here are the dependencies:

dependencies {
    compile('org.mongodb:mongodb-driver:3.2.2')
    compile('org.springframework.boot:spring-boot-starter-data-mongodb')
}

Not that it matters, since they were not added to the project, but here are the eventual import statements:

import org.mongodb.MongoClient;
import org.springframework.data.mongodb.core.MongoTemplate;
like image 961
pward Avatar asked May 27 '16 15:05

pward


People also ask

How do I view Gradle dependencies in IntelliJ?

To view Gradle dependencies as a diagram, click on the Show Dependencies icon on the Gradle tool window toolbar or use the shortcut Alt+Shift+Ctrl+U on Linux and Windows / Alt+Shift+Cmd+U on macOS.

How do I add a dependency in IntelliJ Gradle?

Click Add and reload your project. IntelliJ IDEA adds a dependency to the build.gradle file. IntelliJ IDEA also adds the dependency to the Dependencies node in the Gradle tool window and to the External Libraries in the Project tool window.

Does IntelliJ IDEA support Gradle project build processing?

Yet, keep in mind that the IntelliJ IDEA compiler does not support some parts of the Gradle project build processing and might cause problems in building your project correctly. Use this list to select how you want to run tests in your project.

Why doesn't IntelliJ recognize some dependencies from my build?

My IntelliJ didn't recognize some dependencies from the build.gradle. My guess is that its a cache thing. So I did the following: Delete the gradle caches directory. Restart IntelliJ and refresh gradle dependencies. This worked for me and seems like a simple solution. Nice! I went to File -> Invalidate Caches/Restart which did the trick.

How do I refresh all registered Gradle projects in IntelliJ?

To resolve this issue, navigate to the Gradle Tool window via View -> Tool Windows -> Gradle Click the highlighted button to refresh all registered Gradle projects after changes have been made to the Gradle file. ‘Refresh all Gradle projects‘ will create/restore project structure for all gradle modules in the IntelliJ project —


1 Answers

Ok, so there is a right-hand menu bar, viz:

enter image description here

And the gradle tab has a refresh option:

enter image description here

That'll do it. Ugh, ide's...

like image 88
pward Avatar answered Sep 21 '22 11:09

pward