Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,620 --> 00:00:02,453
-: Let's go ahead and take care
2
00:00:02,453 --> 00:00:03,780
of our normal housekeeping work.
3
00:00:03,780 --> 00:00:06,723
We'll stop all of our apps and close all of our windows.
4
00:00:23,550 --> 00:00:25,140
And I'll just do a little copy-paste here
5
00:00:25,140 --> 00:00:27,213
in this 04-qualifiers directory,
6
00:00:30,690 --> 00:00:33,273
and I'll rename it as 05-primary.
7
00:00:37,770 --> 00:00:40,120
And I'll go ahead and open this up in IntelliJ.
8
00:00:44,580 --> 00:00:46,653
I'll just do a rebuild on the project.
9
00:01:03,480 --> 00:01:04,590
I'll just do a quick cleanup here.
10
00:01:04,590 --> 00:01:06,120
There's an old folder that we have,
11
00:01:06,120 --> 00:01:06,960
our util folder.
12
00:01:06,960 --> 00:01:07,860
We're not using that anymore.
13
00:01:07,860 --> 00:01:09,063
I'll just delete that.
14
00:01:15,600 --> 00:01:17,550
And now I'll go ahead and remove the code
15
00:01:17,550 --> 00:01:19,623
for the qualifier annotation.
16
00:01:21,750 --> 00:01:24,993
I'll move into this class here, demo controller.
17
00:01:29,100 --> 00:01:31,020
And we had the qualifier annotation.
18
00:01:31,020 --> 00:01:33,393
I'll just remove that piece of code here,
19
00:01:44,430 --> 00:01:45,540
and this should fail, right,
20
00:01:45,540 --> 00:01:48,000
because we have multiple implementations out here
21
00:01:48,000 --> 00:01:49,920
and it's not sure which one it's gonna use.
22
00:01:49,920 --> 00:01:52,770
Let's just go ahead and run it real quick just to verify.
23
00:02:00,450 --> 00:02:02,730
All right, so we see the issue here.
24
00:02:02,730 --> 00:02:07,020
Application failed to start, multiple implementations,
25
00:02:07,020 --> 00:02:08,639
not sure which one that it should use.
26
00:02:08,639 --> 00:02:10,289
We've seen all this stuff before.
27
00:02:13,080 --> 00:02:14,700
Down in the action section, this is where it gave you
28
00:02:14,700 --> 00:02:17,340
some hints or tips on how to resolve this issue.
29
00:02:17,340 --> 00:02:18,420
All the way over to the right,
30
00:02:18,420 --> 00:02:19,920
we already saw the example here of using
31
00:02:19,920 --> 00:02:21,030
the qualifier annotation.
32
00:02:21,030 --> 00:02:22,770
We implemented that already,
33
00:02:22,770 --> 00:02:26,220
but notice here they also mentioned the primary annotation.
34
00:02:26,220 --> 00:02:29,100
Hmm. Okay. So let's mark one of the beans as primary.
35
00:02:29,100 --> 00:02:30,500
All right. Let's try it out.
36
00:02:40,350 --> 00:02:43,110
I'll move into my TrackCoach here and expand my window,
37
00:02:43,110 --> 00:02:44,223
zoom in a bit,
38
00:02:45,690 --> 00:02:48,123
and I'll use the primary annotation here.
39
00:02:52,260 --> 00:02:53,760
Basically what I'm saying here is since there are
40
00:02:53,760 --> 00:02:54,780
multiple implementations,
41
00:02:54,780 --> 00:02:58,053
then make the TrackCoach as the primary coach.
42
00:03:10,200 --> 00:03:12,060
In our demo controller,
43
00:03:12,060 --> 00:03:13,200
one thing to notice here,
44
00:03:13,200 --> 00:03:15,000
since we're using Primary and demo controller
45
00:03:15,000 --> 00:03:16,500
there's no need to use Qualifier
46
00:03:16,500 --> 00:03:18,290
because we have a Primary coach.
47
00:03:18,290 --> 00:03:20,640
In this example, we set it up on the TrackCoach
48
00:03:21,930 --> 00:03:23,940
such to resolve any issues or questions
49
00:03:23,940 --> 00:03:26,550
that Spring may have as far as which one to use.
50
00:03:26,550 --> 00:03:27,950
Make use of the Primary one.
51
00:03:30,180 --> 00:03:32,130
Let's go ahead and run our application,
52
00:03:36,420 --> 00:03:38,700
and success. The application starts successfully.
53
00:03:38,700 --> 00:03:39,690
So there's no problem,
54
00:03:39,690 --> 00:03:40,920
there's no errors.
55
00:03:40,920 --> 00:03:42,630
Spring knows which one of the coaches
56
00:03:42,630 --> 00:03:44,190
it should use because we're making use
57
00:03:44,190 --> 00:03:45,753
of the primary annotation.
58
00:03:48,720 --> 00:03:50,160
Swing over into my web browser.
59
00:03:50,160 --> 00:03:53,520
Go to local host 8080/daily workout,
60
00:03:53,520 --> 00:03:54,990
and I should get a track workout.
61
00:03:54,990 --> 00:03:55,823
Excellent.
62
00:03:55,823 --> 00:03:58,530
Run a hard 5K because here we're making use
63
00:03:58,530 --> 00:04:01,083
of that TrackCoach because it's primary.
64
00:04:06,090 --> 00:04:07,500
Alrighty, swing back in,
65
00:04:07,500 --> 00:04:10,230
and let's try and break it on purpose.
66
00:04:10,230 --> 00:04:12,240
I love to do this stuff. This is always fun.
67
00:04:12,240 --> 00:04:15,480
So let's go ahead and add multiple primary components
68
00:04:15,480 --> 00:04:17,043
and let's see what happens.
69
00:04:19,529 --> 00:04:22,470
We know that TrackCoach is already primary.
70
00:04:22,470 --> 00:04:25,620
Let's go ahead and make CricketCoach primary.
71
00:04:25,620 --> 00:04:27,960
All right? We're trying to add multiple primaries,
72
00:04:27,960 --> 00:04:30,183
and, hey, what will Spring do?
73
00:04:34,380 --> 00:04:36,483
Alrighty, so that's in place. Save that.
74
00:04:37,560 --> 00:04:40,470
Your app should reload automatically,
75
00:04:40,470 --> 00:04:44,850
and it's gonna reload and it's gonna fail on the reload.
76
00:04:44,850 --> 00:04:46,290
So if we scroll up a bit
77
00:04:46,290 --> 00:04:48,573
and take a look at the error message,
78
00:04:50,700 --> 00:04:54,180
it says, "Unsatisfied dependency exception."
79
00:04:54,180 --> 00:04:55,013
Okay?
80
00:04:57,060 --> 00:04:59,670
In all this ugly stacked tray stuff,
81
00:04:59,670 --> 00:05:02,100
they're creating bean with demo controller.
82
00:05:02,100 --> 00:05:03,090
Okay?
83
00:05:03,090 --> 00:05:04,710
Blah, blah, blah.
84
00:05:04,710 --> 00:05:07,123
And unsatisfied dependency.
85
00:05:07,123 --> 00:05:08,160
Okay?
86
00:05:08,160 --> 00:05:12,690
So no qualifying bean of type coach available.
87
00:05:12,690 --> 00:05:15,540
And, oh, look at this.
88
00:05:15,540 --> 00:05:18,270
More than one primary bean found
89
00:05:18,270 --> 00:05:19,710
among the candidates.
90
00:05:19,710 --> 00:05:20,543
All right?
91
00:05:20,543 --> 00:05:21,780
So Spring figured us out.
92
00:05:21,780 --> 00:05:24,000
It says, "Hey, you have too many primaries out here.
93
00:05:24,000 --> 00:05:25,170
You can't do that."
94
00:05:25,170 --> 00:05:27,630
And so that's the main issue, that's the root cause.
95
00:05:27,630 --> 00:05:29,400
Okay? And, of course, we can resolve that
96
00:05:29,400 --> 00:05:32,583
by simply having a single primary component.
97
00:05:38,460 --> 00:05:41,040
And so I'll just do that here by just going to CricketCoach,
98
00:05:41,040 --> 00:05:44,730
removing that primary annotation, saving,
99
00:05:44,730 --> 00:05:48,201
and it should reload and reload successfully.
100
00:05:48,201 --> 00:05:49,034
Okay, great.
101
00:05:49,034 --> 00:05:51,750
So our app is up and running and everything's up.
102
00:05:51,750 --> 00:05:53,340
I can go and access that link,
103
00:05:53,340 --> 00:05:55,620
and I should get the track workout on a hard 5K.
104
00:05:55,620 --> 00:05:56,453
Okay, great.
105
00:05:57,630 --> 00:05:58,950
All right, so this is a good example
106
00:05:58,950 --> 00:06:01,440
of handling the issue of multiple implementations
107
00:06:01,440 --> 00:06:03,747
by making use of the primary annotation.
108
00:06:03,747 --> 00:06:06,480
And just swinging back into our demo controller here,
109
00:06:06,480 --> 00:06:08,970
we see that there's no need to use Qualifier
110
00:06:08,970 --> 00:06:10,710
because we actually have a primary coach,
111
00:06:10,710 --> 00:06:12,270
and by swinging over to TrackCoach here,
112
00:06:12,270 --> 00:06:14,130
you can see that this given TrackCoach
113
00:06:14,130 --> 00:06:16,056
is marked as primary.
114
00:06:16,056 --> 00:06:16,889
All right.
115
00:06:16,889 --> 00:06:18,360
So good job, good job.
116
00:06:18,360 --> 00:06:19,193
I'm very happy.
8646
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.