Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Instructor: This video will cover the primary annotation.
Now resolving the issue with multiple coach implementations,
we saw the example in the previous set of videos,
of, by making use of the qualifier annotation.
We were super specific, by mentioning a coach by name.
However, there's an alternate solution available.
Instead of specifying a coach by name,
using a qualifier annotation,
I could say, you know what?
I simply need a coach.
I don't care which coach.
And I could say, Hey, if there are multiple coaches
out there, then you coaches figure it out.
You all tell me who's the primary coach.
I really don't care.
I simply need a coach to help me out, here.
That's it.
So as before, we had our multiple coach implementations,
our track coach, baseball coach,
tennis coach, and cricket coach.
And then the one thing to notice here is,
that now we make use of this new annotation primary.
So this annotation basically says,
out of the multiple coach implementations, this is
going to be the primary implementation that you should use.
Now we can resolve this using the primary.
So here's our code for our demo controller.
And now one thing to notice here, with our demo controller,
and our constructor injection, is that there's no need
to use the qualifier annotation.
Because now, if there's multiple coaches,
we know the primary coach, based on that primary annotation,
that's on the track coach.
All right, so notice the difference, here.
There's one caveat, here.
When you are using the primary annotation, and you probably
was wondering about this, and thought about this.
When using the primary annotation can have only one
for multiple implementations.
If you mark multiple classes with primary, then hmm,
we have a little problem.
And when you run your application, if you try to
mark multiple classes with primary,
then, in the error messages it'll say, Hey,
more than one primary bean found.
So spring will say, I don't know what
you want me to do, here.
There's more than one primary.
I'm not sure which one to use, so I'm not going to start.
All right.
So just have to be aware of that.
You can only mark one class with primary.
Now, you may also wonder, well, what about
mixing primary and qualifier at the same time?
Can I use both of those in the same class?
The answer is yes, but you're asking for trouble.
Not really, but you have to be aware of this is,
that qualifier has the higher priority.
So even if you mention a given class as the primary class,
that can be overridden, or have higher priority,
by making use of the qualifier annotation.
So in this example here, qualifier has a higher priority.
So even though there's a primary coach, track coach,
this example will actually make use of cricket coach.
All right, so just something to be aware of.
And so you may wonder, well, which one should I use?
Should I use primary, or should I use qualifier?
Well, primary leads it up to the implementation classes.
You could have issues of multiple primary classes,
leading to an error.
Qualifier allows you to be very specific
on which bean you want.
And so in general, I recommend using qualifier,
and the reasoning is, is that it's more specific,
and it also has a higher priority,
compared to primary annotation.
This all looks pretty good.
Let's go ahead and move into the video, and let's go ahead
and write some code using the primary annotation.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.