I'm trying to setup an app written in Kotlin, built on Maven and using Spring Boot in Eclipse.
I manage to run the application only if I do Maven build of the project which generates class files in target/classes dir. If I do clean the project then Eclipse rebuilds it automatically and removes all class files from target/classes dir.
I think that re-build of the project should re-compile class files in target/classes directory, not just to remove them. Otherwise it means that I need to re-build project as Maven on each code change which I seems to be a wrong way to go.
Please point me the correct way to setup a Kotlin - Maven - Spring Boot project in Eclipse.
My setup is:
- Eclipse is 4.26.0.
- Maven EMBEDDED 3.8.6.
- Kotlin Plugin for Eclipse 0.8.24 (it causes intallation of Enhanced Kotlin for Eclipse plugin).
- Spring Tools 4 - 4.17.2.RELEASE.
- OpenJDK 11.0.2.
What I did:
- Installed all the above (Eclipse, plugins, JDK and etc).
- Imported the project as a Maven project in Eclipse: github link.
- Right click on DemoApplication.kt -> Run As -> 1 Kotlin Application. I got an error:
Error: Could not find or load main class com.example.demo.DemoApplicationKt
Caused by: java.lang.ClassNotFoundException: com.example.demo.DemoApplicationKt
- Right click on pom.xml -> Run As -> 2 Maven build...
- Goals: clean install -> Run.
- After that I see in
{project dir}\target\classes\com\example\democlass files were generated. - If then I do right click on DemoApplication.kt -> Run As -> 1 Kotlin Application it runs OK.
- If I click on Project -> Clean... (with Build Automatically ON) - all files from
{project dir}\target\classes\com\example\demogot removed and I again start at point 3.
I tried couple configuration options, but they didn't help:
- Making Window -> Preferences -> Java -> Compiler -> Building -> Output folder -> Scrub output folders when cleaning projects OFF doesn't help - class files still got removed.
- In Package Explorer -> Kotlin Runtime Library there is a virtual directory kotlin_bin which has all class files. I tried to setup it as Dependencies:
Run Configuration dependencies setup
But it fails to run then with the below error: