Answer the question
In order to leave comments, you need to log in
Why is @Qualifier needed if there is nothing after it?
Good evening!
There is a Kotlin file that declares many different annotations in a list (the first two are for example):
import javax.inject.Qualifier
@Qualifier
annotation class WithErrorHandler
@Qualifier
annotation class UseCaseScope
..
@Qualifier("appContext1")
Answer the question
In order to leave comments, you need to log in
I figured it out. There are @Qualifier from different packages. Both of them are about DI (dependency injection).
In real life, a situation may arise when several beans of the same type are created (for example, with 1 and the same interface), but in a specific case, for example, a specific bean is needed. @Qualifier - the annotation allows you to specify which one.
1) There is a @Qualifier that is imported from the CDI package JSR 330 (CDI is the Java standard for contexts and dependency injection, and JSR-330 is a subset of it that it fully supports), imported like this:
import javax.inject.Qualifier
Its qualification is not added, just written like this:
@Qualifier
2) There is a @Qualifier that is imported from the Spring framework package (a dependency injection framework), imported like this:
import org.springframework.beans.factory.annotation.Qualifier
@Qualifier("appContext1")
What do I understand wrong?
But after all, after the annotation, there are no brackets in which something would be specified, for example:
@Qualifier("appContext1")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question