Skip to content
Advertisement

Dependency injection with @Inject and Interface in Quarkus

I’m trying to resolve dependency injection with Repository Pattern using Quarkus 1.6.1.Final and OpenJDK 11. I want to achieve Inject with Interface and give them some argument(like @Named or @Qualifier ) for specify the concrete class, but currently I’ve got UnsatisfiedResolutionException and not sure how to fix it.

Here is the my portion of code.

UseCase class:

JavaScript

Repository Interface:

JavaScript

Repository Implementation:

JavaScript

And here is a portion of my build.gradle’s dependencies:

JavaScript

When I run this (e.g. ./gradlew assemble or ./gradlew quarkusDev ), I’ve got the following errors:

JavaScript

Do you have any ideas how to fix this? or is it wrong idea to implement this kind of interface injection and specify the concrete class with argument/annotation?

I’ve read and tried the following articles:

Some official docs:

The other blogs and SOs:

Advertisement

Answer

My guess is that you need to add a scope annotation to your ProductStockDummyRepository. Probably either @Singleton or @ApplicationScoped.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement