Maven Dependencies Red underlines
I have a Maven project (obviously). Several of the dependencies, but not nearly all, have red underscores in the Maven Projects window. If I do a Build/Rebuild Project everything builds fine. From the Maven Projects window if I execute a compile goal it works without error. If I do an external mvn compile it works great If I look in my local maven repository all the files are right where they belong. In short everything except these underscores is perfect.
This is a mature production project, and on other team member's PCs, as well as my old one, it doesn't have this problem. I've read that Intellij will also use the underscore to denote a conflict as well as missing dependency. But conflict doesn't make any more sense than missing.
What steps can I take to further diagnosis this problem, or better yet just fix it?
请先登录再写评论。
After many hours one of my teammates asked "Well have you restarted Intellij?" I had not. But trying everything else, including Maven 3.3.9, didn't help anything.
So I closed Intellij and restarted. All the errors are now gone and I am unable to make them come back with repeated reimports, rebuilds, etc.
To say I'm happy would be a pretty significant overstatement. But I am at least somewhat relieved.
Restarting IntelliJ is part of my workflow, which is unfortunate.
Whenever my local maven repo is empty and I do a maven reimport, the dependencies get pulled in and everything builds. I still get red errors and they won't go away until I restart IntelliJ.
I agree with all the suggestions to delete the .idea directory.
I tried a maven clean/compile from both inside and outside the IDE. Both worked, but red squiggles remained.
I tried clean, reimport from the Maven directory. No joy.
I tried restarting IntelliJ. No joy.
I tried Invalidate Caches/Restart. No joy.
Finally, I exited IntelliJ. Deleted the .idea directory. Imported a new project and chose the .pom file to import from. Success.
Easiest for me was to delete the .idea directory and import as a fresh maven project.
Try to reimport/refresh the project with a new Maven version:
If it doesn't help, share idea.log (https://intellij-support.jetbrains.com/hc/articles/207241085).
I was able to make it work by going into "Maven Projects" menu on the right side, then right-clicking on my project's name and "Reimport"
If the red lines persist, you may also have to delete the project entry in File -> Open Recent -> Manage Projects to get rid of the broken project. Not sure how this stuff passes QA but perhaps we are not paying enough for the annual subscription :(
Thanks todd prickett, your solution worked for me.
- Deleted the .idea directory
- And re-imported project again it worked
I was able to solve this issue by deleting .idea folder (backup first, of course), and reimport project to idea.
Similar issue, first the Maven dependencies - Resolved by clearing the packages from the .m2 cache and re-compiling/downloading.
Next restart the Maven Plug-ins were giving troubles and Reimporting as Romain suggested resolved that.
Most of the time when IntelliJ shows maven errors ('red unterlines' in maven tool), there are real problems or a complete remove of the maven project, clear of the .repository cache and IJ restart and select your problem project, right mouse click 'reimport project' eventually resolves it.
However every IJ version I've worked with in the past few years seems to have the same bug that after a successful reimport all problems are solved but the red underlines are not cleared, reimport, resync, nothing helps except a IJ restart. After a restart all red underlines are gone.
Not sure if anyone raised a defect for this particular case yet?
It's pretty apparent that many users seem to have this issue AND that it is not easily reproducible. We have the same issue and remember that at some stage we used wireshark and saw that intellij was going direct to the repo where it would have had to use a http proxy and the idea.log shows connection timeout errors ... we submitted a support request through the website (not tracker) but that disappeared in a black hole.
I would suggest install the latest maven version. then remove .idea folders. restart intellij. Use reimport option. You can generate maven indices also. One of or all the steps should fix this issue. one more thing. Try to install the latest intellij version too.
Just resolved my maven project red underlines by restarting.
I wish I could help by submitting a sample project that showed this error, but a restart is what solves the error, and importing the project from disk is no doubt going to have the same effect as restarting IntelliJ. So when you look at any submitted project, you're highly unlikely to see the bug. Bonus point if you know what this type of bug is called. (It's not Heisenbug).
I've had the same problem. None of the suggestions worked. Then I've noticed that in my settings.xml file the path to the local repository was set different to the one in Intellij. Fixing that, has fixed the issue.
Another type of solution, which worked for me:
Settings -> Find 'Maven' -> Repositories -> Select your local repo and Update
Again, the only issue was Intellisense marking certain entities with redlines - the project was building just fine.
Is there a link or a pointer to the issue that was recently resolved in 2019.2.2?
I am also having this, or a similar issue and running 2019.2.2 on macOS 10.14.6. New library added to a mature Grails project and all of the code using the new library shows red underlines on my machine (but not others), even though the project runs and works fine. All usages of classes from the new library show "Cannot resolve symbol 'foo'".
I have tried invalidating the caches and restarting many times, deleting the jar from the Maven repo and letting it re-download, refreshing Grails dependencies. Nothing seems to fix the red. I have been combing through YouTrack to find other similar issues and hoping a magic fix is in the comments of one those.
I've tried everything here and I still have this problem. I know I'm not original poster, but I figured it didn't make sense to start a new post. I shut down IntelliJ, cleared the log, started it up did a maven clean and package. Everything builds fine, but still have the red underlines.
Didn't want to paste whole log here, but here it is: idea.log
Thanks for any help
Please submit a bug at https://youtrack.jetbrains.com/issues/IDEA with a sample project to reproduce and all the logs starting from importing the project.
Also provide a screenshot showing what exactly is highlighted as an error and what error reason is displayed by IDEA in the tooltip.
Creating a new project to reproduce, I had no problems. I pulled in all my code from the other project and added the dependencies to the POM file and it's still no problem. Annoying that it's not consistent, but if it comes up again, I'll reach out.
I got this problem when being a bit too quick with updating the version number of the dependency; that is before Jenkins was fully done. Restarting solved the the problem for me.
Solved this problem by updating maven indices for that specific dependency.
That would be hard to fix without a reproducible test case.
Please provide support ticket ID, I can see only 2 unrelated support tickets from your email.
Maven proxy is configured per https://maven.apache.org/guides/mini/guide-proxies.html, not via IntelliJ IDEA.
For me, red underlines when away when I made an unrelated change to pom.xml file.
I have the 3.3.9 version of maven but still have red underlines. This is because not all maven plugins behave correctly, that is, do not provide an XSD for its configuration xml which then results in red underlines. It would be very nice if it where possible in IDEA to do something like "suppress warnings" in code for poms. Use an XML comment like <!-- @startIgnoreUnknownXML --> ... <!-- @endIgnoreUnknownXML --> or something like it.
Feel free to create feature request in YouTrack: http://youtrack.jetbrains.com/issues/IDEA.
Created task https://youtrack.jetbrains.com/issue/IDEA-183820
In my case, commenting the dependencies on pom.xml made them disapper on Maven Projects window, and uncommenting them made them appear back without the red lines.
Most suggestions here didn't fix it in my case so I tried this before deleting .idea folder and it fixed.
None of the previous suggestions worked for me but when I added '<version> ' to the pom.xml, the red lines disappeared after re-importing. When I removed the line again, the red lines came back. The maven worked before even without the version, but for some reason it was required now.