Intellij is giving me errors all around for brand new kotlin/spring project and I cannot build or run the project from the IDE.
If I do it from the command line howe
This issue comes up if you set up your own module inside IntelliJ and you think that since you are doing a Kotlin (Maven) project, the SDK should be set to Kotlin. Wrong!
The problem is shown in the first image. The project SDK is set to Kotlin.
Change it to Java. Probably any 8+ Java will be good enough.
This solves the IDE errors and the compiler errors as well.
Unset KOTLIN_HOME
and other Kotlin- or Java-related settings you may have in your environment (env
to check, unset NAME
to unset.)
Then kill any Gradle daemon still running (pkill -f GradleDaemon
) and test your Gradle build from the terminal. If all goes well, remove the .idea
directory; restart IDEA, making sure to run it without the stray environment variables (for example, launch idea.sh
from the terminal where you unset them); and re-import your project, with the choice of using the default Gradle wrapper.
If you need to use standalone Kotlin versions, installed for example through SDKMAN, consider taking the SDKMAN activation lines out of your shell init file (.bashrc
for Bash) and into a standalone script (say, ~/bin/sdkman
) that will also change your shell prompt (PS1
in Bash) to remind you that you have entered a SDKMAN-managed CLI session.