Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
1
00:00:01,333 --> 00:00:02,722
Hey, in this video,
2
2
00:00:02,722 --> 00:00:04,635
we're gonna learn how to use components
3
3
00:00:04,635 --> 00:00:06,552
in the default bean id.
4
4
00:00:08,247 --> 00:00:10,466
Well, so far we've already learned
5
5
00:00:10,466 --> 00:00:14,786
how to specify the bean id in the component annotation.
6
6
00:00:14,786 --> 00:00:16,410
So with our previous example,
7
7
00:00:16,410 --> 00:00:17,986
we had tennis coach
8
8
00:00:17,986 --> 00:00:19,914
and we have at component,
9
9
00:00:19,914 --> 00:00:22,243
and we give that silly coach.
10
10
00:00:22,243 --> 00:00:24,091
That's the bean id that we'll use
11
11
00:00:24,091 --> 00:00:25,674
in our application.
12
12
00:00:28,429 --> 00:00:32,277
So we can actually remove the actual bean id
13
13
00:00:32,277 --> 00:00:36,526
and let Spring generate a default bean id.
14
14
00:00:36,526 --> 00:00:40,019
The default bean id is basically the class name
15
15
00:00:40,019 --> 00:00:43,898
and they simply make the first letter lowercase.
16
16
00:00:43,898 --> 00:00:46,887
As an example, if we are a class of tennis coach
17
17
00:00:46,887 --> 00:00:48,484
with a capital t,
18
18
00:00:48,484 --> 00:00:51,365
then if we don't specify a bean id,
19
19
00:00:51,365 --> 00:00:54,631
the default bean id will be tennis coach
20
20
00:00:54,631 --> 00:00:56,214
with a lowercase t.
21
21
00:00:58,949 --> 00:01:00,293
Okay, so let's kind of walk through this
22
22
00:01:00,293 --> 00:01:01,311
with a code example.
23
23
00:01:01,311 --> 00:01:03,143
So notice here I have tennis coach
24
24
00:01:03,143 --> 00:01:04,894
and I have at component.
25
25
00:01:04,894 --> 00:01:08,977
Note here, I didn't explicitly specify a bean id.
26
26
00:01:09,826 --> 00:01:12,685
So again, we have the class name of tennis coach,
27
27
00:01:12,685 --> 00:01:15,054
our default bean id will be tennis coach
28
28
00:01:15,054 --> 00:01:16,288
with a lowercase t,
29
29
00:01:16,288 --> 00:01:18,466
so they'll take the first letter of the class
30
30
00:01:18,466 --> 00:01:20,766
and make it lowercase.
31
31
00:01:20,766 --> 00:01:24,072
Now let's look at how we could use this in code now.
32
32
00:01:24,072 --> 00:01:25,982
In our code to actually retrieve the bean
33
33
00:01:25,982 --> 00:01:27,410
from the container,
34
34
00:01:27,410 --> 00:01:29,337
I'd say context get bean,
35
35
00:01:29,337 --> 00:01:31,362
and I give the default bean id,
36
36
00:01:31,362 --> 00:01:32,432
which is tennis coach,
37
37
00:01:32,432 --> 00:01:34,483
which starts with a lowercase t,
38
38
00:01:34,483 --> 00:01:36,128
and that'll actually give me the bean
39
39
00:01:36,128 --> 00:01:38,023
from the Spring container.
40
40
00:01:38,023 --> 00:01:40,985
So again, notice here we're using the default bean id
41
41
00:01:40,985 --> 00:01:45,037
since our class didn't explicitly specify a bean id.
42
42
00:01:45,037 --> 00:01:47,203
And that's pretty much it.
43
43
00:01:47,203 --> 00:01:48,689
So what we'll do in the next video
44
44
00:01:48,689 --> 00:01:50,393
is we'll actually move into Eclipse
45
45
00:01:50,393 --> 00:01:52,609
and we'll actually work through this example,
46
46
00:01:52,609 --> 00:01:55,169
and we'll see how we can actually modify our code
47
47
00:01:55,169 --> 00:01:56,900
to make use of the default bean id,
48
48
00:01:56,900 --> 00:01:59,633
and then also retrieve it from the container.
49
49
00:01:59,633 --> 00:02:02,466
So I'll see you in the next video.
4000
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.