I wanted to get started with Micronaut using Kotlin in IntelliJ. I can setup this exmaple project from github. Running the project with gradle works just fine. Still IntelliJ will not let me import any annotation from javax.inject
. The editor will always display import javax.inject.Singleton
as compilation error (e.g. red font). Mouse over displays
Unresolved reference: Singleton
Browsing External Libraries in the project tree shows a dependency javax.inject:javax.inject:1
that should contain said annotations but it is displayed as empty folder.
Since IntelliJ is using gradle for building the build works without compilation error. As mentioned in the docs: annotation processing is enabled in IntelliJ.
Am I missing something or is this broken in IntelliJ (Build #IU-202.6397.94, built on July 27, 2020, Kotlin plugin 1.4.0)
Since Micronaut 3.0, micronaut Gradle plugin adds new jakarta.inejct
artifact automatically. No need add it explicitly.
Try to build the project by command line(./gradlew build
) in Intellij IDEA terminal windows, then refresh the project in the Gradle pane.
Check my example to demo Kotlin and Kotlin Coroutines.