I am having trouble compiling a Maven project in IntelliJ.
mvn clean install
from commandline = SUCCESSTherefore I don't believe there is anything wrong with the project itself. But
I have
What else could I try to make IntelliJ intelligent enough to compile the project?
This can happen if command line uses a different version of mvn than IntelliJ. Make sure that Intellij is using the same maven executable that command line is using. First type: "which mvn" to find out the mvn executable that command line is using. Then make IntelliJ use the same version by going to: Intellij => Preferences => Build, Execution and Deployment => Build Tools => Maven => Maven Home Directory. Mvn Settings in IntelliJ 2017.1
Just ran into this problem. What worked for me was to close the project and delete the .idea folder.
Reopened the project then set it up as a maven project again...
All good after that.
Check the JDK setting for the project. In my experience, that is the most common cause of bizzare Intellij-cannot-compile problems.
Under "Project Settings" (CMD-,) - see the "Project SDK" setting.
Make sure it's a valid SDK, and the version matches the required version for the sources (ie check the maven compiler plugin source/target settings, and make sure the selected SDK is at least that version, or higher).
After a few years, I came across the same issue again but with another project. In this case IntelliJ was missing the Lombok plugin which generates the missing sources.
To install:
I've had this issue when I've had generated sources. Maven wasn't setup to mark the compiled-test-sources folder as a test sources root, so every time I did something with Maven I had to mark the generated folders.
I encountered a similar issues with compiling to Java 11 from IntelliJ Maven compile indicating that com.sun.management.HotSpotDiagnosticMXBean#dumpHeap()
did not exist.
After trying the above steps, I still could not get it to resolve. I had recently migrated to a new instance of Ubuntu and decided to fire up my old VM, where the code compiled without an issue. So it occurred to me that when I installed IntelliJ on the new VM, I chose to download AdoptOpenJDK 11 ( adopt-openj9-11.0.7 ) via IntelliJ SDK download feature.
So I manually downloaded and installed a fresh copy of OpenJDK 11 ( jdk-11.0.6+10 ), then changed the project's default SDK to the new one I installed, and everything compiled just fine.
I hope this answer may help others.
Have been facing this issue for long now, and usually the root cause for it is different maven version running on IntelliJ as mentioned above, but also sometimes it can be caused by different version of Java selected in the project structure.
As for me even after aligning the maven version the issue would not go, but once I checked the java version, Intellij had by defaulted selected Java 11 for me, and once I changed it back to Java 8, it started working again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.