error running maven tool in intellij - "SDK 17 is not compatible with the source version 17" Follow
Answered
I have a module that uses maven and java 17. It compiles fine from the command line with mvn. When I try to use the intellij Maven tool (on right sidebar) to run the install lifecycle, I get this error:
invalid target release: 17
Module my-module SDK 17 is not compatible with the source version 17.
Upgrade Module SDK in project settings to 17 or higher. Open project settings.
The module SDK is set to 17 (17.0.1) in the project settings. Not sure what is wrong.
Thanks
Please sign in to leave a comment.
What is the language level set for project and SDK set for the module?
Please share the screenshot of your project and module settings.
Hello Konstantin,
The project SDK is 1.8 and the project language level is 8. The module SDK is 17 and the module language level is 17 (preview).
Where does the Maven run? 8, or 17? Check the "Preferences | Build, Execution, Deployment | Build Tools | Maven | Runner" by default, project's JDK is chosen rather than module's one.
Dear, Konstantin Annikov
I got the same issue. I don't understand your solution clearly. Can you have a better instruction?
Nguyen Duc Y
Go to File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner dialog. What is the version of the JRE selected there?
I had same issue in multimodule maven project with libs for spring-boot projects. Used spring-boot-dependencies 2.7.3, jdk-17.0.5 libs. I upgraded Idea to 2022.2.3 UE, sets version 17 in all above locations. Maven builds successfully several modules but fails in one with absolutely same settings with error: module [bla-bla-bla] SDK 17 is not compatible with the source version 17. Removing of one dependency org.apache.kafka:kafka-clients:2.5.1 helped me, error disappears
I had the same issue. I created Spring Boot 3.0 application with Java 17, opened it in Intellij IDEA and I couldn't build it because of almost the same error as OP mentioned. In project settings version 17 was chosen. And I don't have Kafka in pom.xml, like person above.
It appears that even though I could choose version 17, the downloaded SDK was in version 16. I downloaded SDK 19, selected version 17 afterwards and project built successfully.
Please help what to do in this case
Hello,
What source/target level is configured in your pom.xml file?
Hi Yaroslav.
I have enconterd same error. My project Runner is below
module setting:
Run/debug configuration:
and my pom.xml
Whan can I do to cope this error?
Hello,
I changed it like bellow and error gone away.
https://intellij-support.jetbrains.com/hc/en-us/community/posts/4424982618258/comments/9232966890002
Same 225101403 mentioned on the screens
Same initial settings with 225101403.
But solved the problem by setting Project Structure -> Modules -> Language level to 8 instead of removing those two maven.compiler lines.