-1

Upon IntelliJ IDEA > File > New > Project from Existing Sources... > Import project from external model > Maven, I can't successfully mvn compile.

Instead Maven fails that with..

[ERROR] COMPILATION ERROR :
...
The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

.. on seemingly every classtype (not just Object as above) in the project.

How can I configure my IntelliJ to successfully mvn compile?


[Questions that are similar to this, but not exactly the same (although maybe tangentially helpful)]:

  • Why so red? IntelliJ seems to think every declaration/method cannot be found/resolved
    • Nothing is red in my IntelliJ IDEA
  • Intellij Cannot resolve symbol on import
    • Sounds like the wording of that [error?], "Cannot resolve symbol on import", is similar but different from mine ("The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files")
    • A text search of that page also [CMD+F / Ctrl+F], for parts of my specific Error message {"cannot be resolved", "indirectly referenced", ".class"}, shows no matches - which further leads me to think that Question is slightly different
    • Question itself makes no mention of Maven
cellepo
  • 4,001
  • 2
  • 38
  • 57

1 Answers1

0

Make Project SDK match Module SDK

I happened to have a mismatch of configured SDK...

  1. Project window > right-click your [Maven] Project > Open Module Settings > Project Settings
  2. Set these to match on their SDK (and maybe also Language level):
    • Project > SDK
    • Modules > Dependencies > Module SDK
  3. Now try to mvn compile again
cellepo
  • 4,001
  • 2
  • 38
  • 57