cmoetzing
cmoetzing

Reputation: 792

javax.inject imports missing in IntelliJ for Micronaut Kotlin project

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)

Upvotes: 4

Views: 1280

Answers (2)

Hantsy
Hantsy

Reputation: 9241

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.

Upvotes: 1

Kr10n1
Kr10n1

Reputation: 23

Micronaut 3 M2 Released

This should answer your question. Adding this below to dependencies should help if you prefer using javax

implementation("javax.inject:javax.inject:1")

Upvotes: 2

Related Questions