0

I'm just getting started with Micronaut and one thing I was surprised to discover is that despite the annotation processors, there does not appear to be any warnings to indicate when there is a dependency injection problem. For Example, when I have an @Inject for an interface with 2 concrete implementations. I was expecting my IDE to provide a compiler warning on the inject annotation telling me that there are 2 possible bindings and I would need to provide a @Named annotation to disambiguate.

Is my expectation incorrect and binding problems are still only revealed at runtime, or have I not configured my IDE correctly to properly inform me of these DI errors using Micronaut?

Java version: 8
IDE: IntelliJ IDEA Ultimate
Micronaut Version: 1.1.1
Build Tool: maven
Matthew Madson
  • 1,643
  • 13
  • 24

1 Answers1

0

Because there are 2 available at compile time does not mean that there will be 2 available at runtime.

Folks have asked the same question the other way around wondering why we can't report at compile time that a bean does not exist and the answer is that just because it doesn't exist at compile time does not mean that it won't exist at runtime. You don't know at compile time what will be on the classpath at runtime, beans can be configured to be conditionally loaded based on runtime conditions, etc.

EDIT

I realize that I didn't explicitly address your questions...

Is my expectation incorrect and binding problems are still only revealed at runtime, or have I not configured my IDE correctly to properly inform me of these DI errors using Micronaut?

The answer to the first part is yes, your expectation was incorrect. The answer to the second part is that your IDE configuration isn't relevant to the behavior in question.

I hope that helps.

Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47