IntelliJ Ultimate 2022.3: Spring Boot Gradle project runs, but editor can't find dependency imports

Answered

Hi,

Since I updated to IntelliJ Ultimate 2022.3, my Spring Boot Gradle project is messed up: I can build, run & debug it. But the editor doesn't find any import from a Gradle dependency:

Here's what I tried to fix it:

  • Building and rebuilding the project
  • Reload Gradle configuration
  • Refresh Gradle dependencies
  • Unlink Gradle project (and re-linking it again)
  • Invalidate Caches
  • Repair IDE
  • Disabled a lot of plugins

Does anybody know how to fix this?

Here's my setup:

IntelliJ IDEA 2022.3 (Ultimate Edition)
Build #IU-223.7571.182, built on November 29, 2022
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.6.1
GC: G1 Young Generation, G1 Old Generation
Memory: 8200M
Cores: 10
Metal Rendering is ON
Registry:
    ide.mac.alt.mnemonic.without.ctrl=false
    debugger.watches.in.variables=false
    ide.allow.merge.buttons=false
    ide.balloon.shadow.size=0

Non-Bundled Plugins:
    com.github.copilot (1.1.37.2188)
    Dart (223.7571.203)
    org.mapstruct.intellij (1.4.0)
    io.flutter (71.0.6)
    zielu.gittoolbox (213.10.2)

Kotlin: 223-1.7.20-release-201-IJ7571.182

1
13 comments

I uninstalled IntelliJ and started fresh, with a new application directory. Didn't help either. 

I created a new project with Spring Initializr for comparison and found that somehow, in my project, the Gradle JAR files aren't read. Here's the Lombok library in my "External Libraries" list at the bottom of my project - no classes shown:

In the new project, classes are there:

In my broken project, I selected the Lombok JAR file and chose "Open in - Finder". The JAR file exists. But it is in a different directory:

  • Broken project: /Users/karsten/.m2/repository/org/projectlombok/lombok/1.18.24/lombok-1.18.24.jar
  • Good project: /Users/karsten/.gradle/caches/modules-2/files-2.1/org.projectlombok/lombok/1.18.24/13a394eed5c4f9efb2a6d956e2086f1d81e857d9/lombok-1.18.24.jar
0

I switched back to IntelliJ 2022.2.4 - and my problems are solved!

0

Running "File | Invalidate Caches" might help in such cases.

0

It did not. As I said in my original post, I emptied caches and repaired the IDE to no avail. Reinstalling with a new application directory didn't help either. The only thing that helped immediately: Going back to IntelliJ 2022.2

0

Is it reproducible with some sample project (created in old version and opened in new one)? Could you please share build.gradle file from broken project?

0

Maybe next week. I lost a day this week to this problem already.

 

0

Thanks in advance! I'll be waiting for a feedback.

0

This is same for me. Sometimes it does not import libraries even if they are in the project. I add them manually by typing dependency path.

0

Could you please provide us with a sample project to reproduce a problem? You can share it using JetBrains Uploads and write the ID you receive here.
Also, please, try to perform the following actions:

  • File | Invalidate Caches... | Invalidate and Restart
  • close the project window File | Close Project and IntelliJIDEA;

  • open your project in OS file explorer and remove all *.iml files and the .idea folder from your project;

  • delete .m2/.gradle folder;

  • re-import the project into IDEA from Existing sources.

0

For me, the problem initially only showed in IntelliJ 2022.3 and went away with IntelliJ 2022.2. But then it appeared in IntelliJ 2022.2 as well. Here's how.

I checked out another branch of my project in a new folder. To configure the new project correctly, I went into the "Module Settings" of my existing project. And that was my mistake: Those existing settings were messed up and wouldn't close the dialog. I think I usually get multiple "root modules" for my project in "Project Settings - Modules", and they had some errors. Also, IntelliJ complained about missing JAR sources in "Problems". Don't remember, to be honest.

So I clicked around the settings of my existing project to make IntelliJ happy and to save. I finally managed, but boom - the editor didn't find any import from a Gradle dependency. 😫

So I upgraded to the new IntelliJ 2022.3 (again). Same problem. Deleted my IntelliJ folder in my macOS "Library" folder and started fresh as a new 2022.installation. No luck, either.

Eventually, I found that, somehow, my IntelliJ preferences were messed up. I use the IDE Settings Sync and had always synced all settings. That was the root cause: The synced settings somehow caused my "didn't find any import from a Gradle dependency" problem!

So I deleted my IntelliJ folder in my macOS "Library" folder and started fresh as a new 2022.installation once more. But this time, I only syned "UI Settings" and "Keymaps". And the problem of "didn't find any import from a Gradle dependency" finally went away! I then did all my local configuration and gradually enabled the sync setting categories, having my local settings overwrite the remote ones. Now  all my setting categories sync, and my 

1

Karsten Silz, in the 2022.3 IDE version, we introduced the new Settings Sync plugin, so when you update your IDE for the first time, settings from your previous plugin should migrate into the new one.
Sometimes, errors occur, and the migration process could go wrong. Probably that's what happened in your case, but it doesn't explain why you met a similar problem after downgrade - all major IDE versions use different configuration directories, and synchronization plugins don't sync between each other (the old plugin can't sync changes made using the new plugin). Since you already deleted your 2022.3 IDEA folder once, unfortunately, we can't restore the original steps of the migration procedure, which led to this problem.

Is everything working fine now? Please, let us know if there are any problems or if some settings weren't synchronized.

0

Olga Mulina So you rewrote the settings sync plugin? That would explain why it was so buggy: When I selected just one category to sync in 2022.3, it synced a bunch of others. 😅

I agree with you: I had this problem in both 2022.2 and 2022.3, so the new settings sync plugin ain't to blame. Whatever was screwed up in my IntelliJ settings is now gone. And I can't reproduce it.

0

Be Sure to comment out local maven repositories from POM and .m2 settings file.

delete .idea file

Reload as an existing maven project .
comment in local maven repositories.

This worked for me

0

Please sign in to leave a comment.