Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,140 --> 00:00:02,370
-: Now, let's just zoom out
2
00:00:02,370 --> 00:00:05,013
for a second and let's run our application.
3
00:00:17,370 --> 00:00:19,530
We see that um
4
00:00:19,530 --> 00:00:21,300
we have a problem, right?
5
00:00:21,300 --> 00:00:22,230
Things didn't work out.
6
00:00:22,230 --> 00:00:25,200
It said application failed to start.
7
00:00:25,200 --> 00:00:26,940
And if we can kind of expand our window here
8
00:00:26,940 --> 00:00:28,260
for a bit and just scroll
9
00:00:28,260 --> 00:00:29,853
through the log messages here.
10
00:00:36,510 --> 00:00:39,240
Parameter zero of the constructor
11
00:00:39,240 --> 00:00:40,960
required a single bean
12
00:00:42,840 --> 00:00:44,640
but three were found.
13
00:00:44,640 --> 00:00:46,197
Hmm, three.
14
00:00:46,197 --> 00:00:48,540
Okay. Baseball,
15
00:00:48,540 --> 00:00:50,460
Cricket, Tennis.
16
00:00:50,460 --> 00:00:51,930
Hey, what about our track coach?
17
00:00:51,930 --> 00:00:52,763
That's strange.
18
00:00:52,763 --> 00:00:56,196
I, I thought, thought we had four.
19
00:00:56,196 --> 00:00:58,569
It's a lot of, um
20
00:00:58,569 --> 00:01:00,540
code that I wrote back there and
21
00:01:00,540 --> 00:01:01,620
um only three.
22
00:01:01,620 --> 00:01:02,453
Hmm.
23
00:01:02,453 --> 00:01:03,286
What's up with that?
24
00:01:03,286 --> 00:01:04,119
Let's take a look.
25
00:01:11,074 --> 00:01:13,770
All right, so we have our baseball coach
26
00:01:13,770 --> 00:01:15,481
we have our tennis coach,
27
00:01:15,481 --> 00:01:16,761
we have our track
28
00:01:16,761 --> 00:01:18,960
Oh, got it.
29
00:01:18,960 --> 00:01:21,900
I forgot to add the component annotation here.
30
00:01:21,900 --> 00:01:24,210
So remember the component annotation marks the class
31
00:01:24,210 --> 00:01:25,440
as a spring bean
32
00:01:25,440 --> 00:01:26,940
since it wasn't marked Spring
33
00:01:26,940 --> 00:01:27,840
Couldn't find it.
34
00:01:27,840 --> 00:01:28,860
Ah, got it.
35
00:01:28,860 --> 00:01:29,810
Okay, cool.
36
00:01:29,810 --> 00:01:32,283
Nice little learning exercise there.
37
00:01:35,026 --> 00:01:35,859
All right
38
00:01:35,859 --> 00:01:37,590
so this looks better now
39
00:01:37,590 --> 00:01:40,270
uh, let's run our app one more time
40
00:01:41,160 --> 00:01:42,410
and see how it works out.
41
00:01:47,340 --> 00:01:48,300
Okay, uh
42
00:01:48,300 --> 00:01:49,755
Application, uh
43
00:01:49,755 --> 00:01:51,952
failed to start
44
00:01:51,952 --> 00:01:54,810
uh, because of our parameter
45
00:01:54,810 --> 00:01:58,020
of the constructor, but four were found.
46
00:01:58,020 --> 00:01:59,790
And so basically we kind of broke it the way we
47
00:01:59,790 --> 00:02:00,750
plan to break it, right?
48
00:02:00,750 --> 00:02:01,829
We plan to break it
49
00:02:01,829 --> 00:02:04,770
with four coach implementations, not three.
50
00:02:04,770 --> 00:02:06,850
So anyway, it, it's broken as desired
51
00:02:12,960 --> 00:02:14,820
here at the bottom to give us some actions that we
52
00:02:14,820 --> 00:02:16,101
could possibly make use of
53
00:02:16,101 --> 00:02:18,214
consider doing this stuff.
54
00:02:18,214 --> 00:02:20,820
And it says, Hey, one of the options is making use
55
00:02:20,820 --> 00:02:23,550
of qualifier annotation to identify the bean
56
00:02:23,550 --> 00:02:24,630
that should be consumed.
57
00:02:24,630 --> 00:02:25,463
Okay, great.
58
00:02:25,463 --> 00:02:26,640
Well thanks for that hint
59
00:02:26,640 --> 00:02:27,720
Let's go ahead and, uh
60
00:02:27,720 --> 00:02:30,243
apply that and uh let's implement that hint.
61
00:02:31,860 --> 00:02:33,860
I'll move into our demo controller here.
62
00:02:35,700 --> 00:02:39,390
Expand the window for a second and zoom in.
63
00:02:39,390 --> 00:02:40,650
And in my demo controller
64
00:02:40,650 --> 00:02:42,710
I'll make use of that qualifier annotation.
65
00:02:42,710 --> 00:02:44,890
So I'll specify the bean ID that I want
66
00:02:47,396 --> 00:02:51,753
and I'll specify the bean ID of baseball coach.
67
00:02:52,770 --> 00:02:54,360
So I'll use the same name as the class
68
00:02:54,360 --> 00:02:56,823
except for the first character is lowercase.
69
00:03:01,260 --> 00:03:02,940
So I'm being super specific saying
70
00:03:02,940 --> 00:03:04,710
Use this implementation
71
00:03:04,710 --> 00:03:06,183
of the coach interface.
72
00:03:08,070 --> 00:03:08,940
Okay, great.
73
00:03:08,940 --> 00:03:10,770
So now we can go ahead and run our application
74
00:03:10,770 --> 00:03:13,090
and, uh see if we have any success
75
00:03:14,970 --> 00:03:18,420
and great, so the application started successfully
76
00:03:18,420 --> 00:03:19,253
All right, so that's good.
77
00:03:19,253 --> 00:03:21,900
So we kind of resolved the whole ambiguity issue
78
00:03:21,900 --> 00:03:24,200
and I can go over to my browser
79
00:03:24,200 --> 00:03:26,980
localhost8080/dailyworkout
80
00:03:27,930 --> 00:03:30,000
and I should get a baseball workout.
81
00:03:30,000 --> 00:03:30,833
Great. So it says,
82
00:03:30,833 --> 00:03:32,820
Hey, spend 30 minutes in batting practice.
83
00:03:32,820 --> 00:03:35,700
And that's coming from our baseball coach implementation.
84
00:03:35,700 --> 00:03:36,533
I like it.
85
00:03:36,533 --> 00:03:37,366
This is really good.
86
00:03:40,350 --> 00:03:42,180
And now let's swing back over and let's kind of
87
00:03:42,180 --> 00:03:43,920
just change this up a bit, uh
88
00:03:43,920 --> 00:03:45,660
based on some configuration here.
89
00:03:45,660 --> 00:03:47,340
So instead of baseball coach,
90
00:03:47,340 --> 00:03:49,320
I'd like to modify to make use
91
00:03:49,320 --> 00:03:50,860
of Track Coach
92
00:03:55,942 --> 00:03:57,390
and it should reload the new version
93
00:03:57,390 --> 00:03:58,390
for me out there
94
00:04:00,180 --> 00:04:03,030
and just do a reload on the browser over here
95
00:04:03,030 --> 00:04:04,920
and run a hard 5k.
96
00:04:04,920 --> 00:04:05,880
Great. I love it.
97
00:04:05,880 --> 00:04:06,713
I love it.
98
00:04:06,713 --> 00:04:07,546
So this is really good.
99
00:04:12,510 --> 00:04:14,463
And then just to kind of set everything back to what we
100
00:04:14,463 --> 00:04:16,589
what we originally had
101
00:04:16,589 --> 00:04:18,420
we'll make use of this Cricket coach
102
00:04:18,420 --> 00:04:20,399
as part of the qualifier here
103
00:04:20,399 --> 00:04:22,260
and it makes sure that we actually load the
104
00:04:22,260 --> 00:04:23,950
Cricket Coach implementation
105
00:04:26,610 --> 00:04:27,900
practice our fast bowling
106
00:04:27,900 --> 00:04:29,970
Awesome. So as you can see here
107
00:04:29,970 --> 00:04:33,090
using a spring object factory spring container
108
00:04:33,090 --> 00:04:37,410
we can actually configure how we want to use a given bean
109
00:04:37,410 --> 00:04:39,930
and how we can inject a given bean based
110
00:04:39,930 --> 00:04:41,340
on the configuration.
111
00:04:41,340 --> 00:04:42,360
So this is really good.
112
00:04:42,360 --> 00:04:45,243
I like to say good job my friend.
7637
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.