Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,607 --> 00:00:01,800
Instructor: Let's go ahead and take care
2
00:00:01,800 --> 00:00:02,969
of our normal housekeeping;
3
00:00:02,969 --> 00:00:05,463
stopping all apps and closing all windows.
4
00:00:20,129 --> 00:00:21,780
And I'll move in here into my file system
5
00:00:21,780 --> 00:00:23,793
into my dev-spring-boot directory.
6
00:00:25,860 --> 00:00:29,190
And into my O2 spring boot core.
7
00:00:29,190 --> 00:00:31,650
And then I'll copy paste our O2 component
8
00:00:31,650 --> 00:00:36,390
scanning directory here and I'll simply rename it
9
00:00:36,390 --> 00:00:37,833
and give it a new name.
10
00:00:39,240 --> 00:00:41,703
And I'll call it 03 setter-injection.
11
00:00:45,870 --> 00:00:48,663
Now go ahead and open up this project in IntelliJ.
12
00:01:04,440 --> 00:01:06,300
And what I'd like to do first is do a rebuild
13
00:01:06,300 --> 00:01:07,143
on the project.
14
00:01:08,456 --> 00:01:10,943
This'll help with auto reloading of spring boot dev tools.
15
00:01:16,200 --> 00:01:18,000
And step one will create the setter method
16
00:01:18,000 --> 00:01:20,008
in our class for injections.
17
00:01:20,008 --> 00:01:21,450
And step two will configure the dependency
18
00:01:21,450 --> 00:01:23,523
with the Autowired annotation.
19
00:01:26,490 --> 00:01:28,940
Let's go ahead and move into our demo controller.
20
00:01:45,240 --> 00:01:47,313
I'll expand my window for a second.
21
00:01:50,520 --> 00:01:54,060
And what I wanna do is delete some of the previous code.
22
00:01:54,060 --> 00:01:56,220
So where we had our constructor injection
23
00:01:56,220 --> 00:01:57,390
I wanna delete this code
24
00:01:57,390 --> 00:02:00,040
because now we're gonna make use of setter injection.
25
00:02:04,410 --> 00:02:06,280
I'll set up Autowired annotation
26
00:02:09,060 --> 00:02:11,500
and I'll create this setter method setCoach
27
00:02:15,953 --> 00:02:18,480
and then I make the appropriate assignments inside
28
00:02:18,480 --> 00:02:19,313
of this method.
29
00:02:24,270 --> 00:02:26,040
Okay, so we have the basic things
30
00:02:26,040 --> 00:02:29,703
in place here for setter injection for our demo controller.
31
00:02:33,750 --> 00:02:37,920
And now let me swing over to my spring boot application.
32
00:02:37,920 --> 00:02:39,900
I'm gonna delete the previous code I had
33
00:02:39,900 --> 00:02:41,940
for all of the scanned based packages.
34
00:02:41,940 --> 00:02:43,860
Just kind of get rid of it for right now.
35
00:02:43,860 --> 00:02:45,180
We already have backups of it
36
00:02:45,180 --> 00:02:46,953
in some of the other directories.
37
00:02:51,142 --> 00:02:52,770
And great so that's all cleaned up now.
38
00:02:52,770 --> 00:02:55,560
Now let's go ahead and run our application.
39
00:02:55,560 --> 00:02:57,460
And our application is up and running.
40
00:03:01,170 --> 00:03:04,590
Just swing over to our browser and we go
41
00:03:04,590 --> 00:03:08,343
to our local hosts 8080/dailyworkout.
42
00:03:09,960 --> 00:03:11,280
And our app's gonna work the same.
43
00:03:11,280 --> 00:03:12,390
We're gonna get the output here
44
00:03:12,390 --> 00:03:15,810
for this cricket coach practice fast bowling for 15 minutes.
45
00:03:15,810 --> 00:03:17,490
So we know that our application is actually
46
00:03:17,490 --> 00:03:19,983
performing the setter injection at this point.
47
00:03:22,415 --> 00:03:25,156
Now what I'd like to do is move in here
48
00:03:25,156 --> 00:03:28,650
and just change this method real quick
49
00:03:28,650 --> 00:03:31,233
just to make the text a little bit different.
50
00:03:32,220 --> 00:03:34,893
Just do a quick save on it should reload for us.
51
00:03:44,997 --> 00:03:47,975
And then swinging back over into our browser reloading
52
00:03:47,975 --> 00:03:49,233
we should see the new output.
53
00:03:49,233 --> 00:03:50,580
So that's our recent update that we have here.
54
00:03:50,580 --> 00:03:51,423
Okay, good.
55
00:03:55,110 --> 00:03:56,430
And now what I'd like to do
56
00:03:56,430 --> 00:04:00,420
in our demo controller is actually make a modification.
57
00:04:00,420 --> 00:04:03,209
So instead of using a traditional setter method,
58
00:04:03,209 --> 00:04:06,603
I want to just give it any method name here.
59
00:04:14,434 --> 00:04:17,010
So instead of set coach, I'll give any method name
60
00:04:17,010 --> 00:04:19,399
I'll call it, I don't know, doSomeStuff.
61
00:04:19,399 --> 00:04:21,089
You can give whatever name you'd like here.
62
00:04:21,089 --> 00:04:23,070
The fact that this method is annotated
63
00:04:23,070 --> 00:04:24,840
with the auto wired annotation
64
00:04:24,840 --> 00:04:27,933
then spring will use this for dependency injection.
65
00:04:31,985 --> 00:04:34,140
Alrighty, so if we save that accordingly
66
00:04:34,140 --> 00:04:35,430
come back over here.
67
00:04:35,430 --> 00:04:37,140
Reload. And our app works just fine.
68
00:04:37,140 --> 00:04:38,010
So we're getting the message.
69
00:04:38,010 --> 00:04:39,970
So we know that our app is working
70
00:04:39,970 --> 00:04:44,850
with injection, based on any method name that we provide.
71
00:04:44,850 --> 00:04:47,300
And again, because of that auto wired annotation.
72
00:04:52,800 --> 00:04:55,263
Just do a quick little update on the method here,
73
00:05:02,640 --> 00:05:03,473
and okay, great.
74
00:05:03,473 --> 00:05:05,768
So we're getting the latest and greatest here.
75
00:05:05,768 --> 00:05:07,463
So this part is working out as desired.
76
00:05:08,730 --> 00:05:11,010
Now what I'd like to do is kind of just swing back
77
00:05:11,010 --> 00:05:13,650
and just put it back to the traditional set of methods
78
00:05:13,650 --> 00:05:15,150
just to make it straightforward
79
00:05:15,150 --> 00:05:16,890
and easy to read and understandable.
80
00:05:16,890 --> 00:05:19,470
Instead of do some stuff, I'll call it set coach
81
00:05:19,470 --> 00:05:21,360
just to, yeah, that's exactly what we're doing,
82
00:05:21,360 --> 00:05:22,450
we're setting a coach
83
00:05:29,580 --> 00:05:30,994
and great.
84
00:05:30,994 --> 00:05:32,280
So that's in place. We're good to go.
85
00:05:32,280 --> 00:05:33,113
We're all set up.
86
00:05:33,113 --> 00:05:34,530
So that's a quick example there
87
00:05:34,530 --> 00:05:37,800
of using setter injection with spring.
88
00:05:37,800 --> 00:05:38,633
Good job.
6817
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.