1
00:00:02,220 --> 00:00:05,800
Until now, we looked at some of the basics of Spring Boot.

2
00:00:06,110 --> 00:00:12,260
And before we go any further, I think it would be great if you can clearly separate what are the differences

3
00:00:12,260 --> 00:00:16,080
between Spring, Spring MVC and Spring Boot.

4
00:00:16,190 --> 00:00:23,180
I think having great clarity on that would be really wonderful. Spring Boot, Spring MVC and Spring.

5
00:00:23,330 --> 00:00:24,410
How do they compare?

6
00:00:24,470 --> 00:00:28,630
That's basically what we would want to answer in this specific step.

7
00:00:28,640 --> 00:00:34,880
Actually, by the end of this, you would understand that Spring, Spring MVC and Spring Boot have their

8
00:00:35,000 --> 00:00:36,300
own roles.

9
00:00:36,310 --> 00:00:38,860
They are not really competing for the same space.

10
00:00:39,050 --> 00:00:44,250
They solve really different problems and they solve them really really well.

11
00:00:44,270 --> 00:00:47,570
So what's the core problem that Spring framework solves?

12
00:00:47,570 --> 00:00:56,960
Think about it. The core problem Spring framework solves is testability. If you don't define proper dependencies

13
00:00:57,050 --> 00:01:00,280
then your applications are not testable.

14
00:01:00,290 --> 00:01:09,170
The most important feature is dependency injection. The core of Spring framework is the IOC -  inversion of control.

15
00:01:09,330 --> 00:01:14,940
Spring framework takes control of all the beans and their dependencies.

16
00:01:15,170 --> 00:01:22,550
That's basically what the Spring	framework cares about. Spring framework is all about defining your beans, putting

17
00:01:22,550 --> 00:01:28,900
your at component, putting your at service and things like that and also defining your dependencies

18
00:01:28,960 --> 00:01:34,670
at auto wired and things like that and also defining how to find your beans.

19
00:01:34,700 --> 00:01:42,680
Components scan for example. Thats basically the core problem that Spring framework solves. Spring framework solves

20
00:01:42,710 --> 00:01:46,030
the problem of dependency injection.

21
00:01:46,040 --> 00:01:53,210
It helps you to build loosely coupled applications. Loosely coupled applications can be easily unit

22
00:01:53,210 --> 00:01:54,020
tested.

23
00:01:54,170 --> 00:02:00,140
If you look at this example, you'll see that welcome service instance is directly created in here.

24
00:02:00,140 --> 00:02:06,170
This is tightly coupled. The welcome controller is now tightly coupled to the welcome service.

25
00:02:06,450 --> 00:02:13,470
However, if you do Dependency Injection properly then you would auto wire it in.

26
00:02:13,490 --> 00:02:21,140
You can use frameworks like Mockito and Mock Spring MVC to replace this service with a mock and unit

27
00:02:21,170 --> 00:02:21,590
test

28
00:02:21,590 --> 00:02:27,550
this controller. Thats the main problem that Spring framework solves.

29
00:02:27,560 --> 00:02:33,340
Other than that, Spring framework also solves a few other problems like duplication and that's basically plumbing

30
00:02:33,340 --> 00:02:34,140
code.

31
00:02:34,200 --> 00:02:40,080
So if, lets say you are using JDBC then you needed to write a lot of boilerplate code.

32
00:02:40,100 --> 00:02:47,600
Try, catch, exception and all that kind of stuff. That's not needed when you use any of the things that

33
00:02:47,600 --> 00:02:51,410
are based on the Spring frameworks, Spring JDBC or Spring JMS.

34
00:02:51,410 --> 00:02:54,380
You don't really need to do that kind of stuff at all.

35
00:02:54,380 --> 00:03:00,590
The other thing with Spring framework solves was providing good integration with other frameworks. So Spring

36
00:03:00,980 --> 00:03:03,930
had good integration with Hibernate ORM.

37
00:03:03,960 --> 00:03:05,640
iBatis for object mapping.

38
00:03:05,780 --> 00:03:08,840
It has good integration with JUnit and Mockito as well.

39
00:03:08,940 --> 00:03:17,810
Spring MVC is concerned with developing web applications. Spring MVC provides a simple way of developing

40
00:03:17,810 --> 00:03:19,700
web applications.

41
00:03:19,700 --> 00:03:26,750
One of the great thing about Spring MVC is the separation of concerns. Dispatchers servlet is concerned

42
00:03:26,750 --> 00:03:32,250
with just the basic front controller part. There is a model and view.

43
00:03:32,420 --> 00:03:39,640
There is a view resolver which is concerned just with resolving a view name to the physical view.

44
00:03:39,770 --> 00:03:46,220
With this kind of simple concepts, Spring MVC makes it very very easy to develop your web applications

45
00:03:46,820 --> 00:03:52,200
as well as your RESTful services. Whether you are developing web applications or REST services with

46
00:03:52,210 --> 00:03:53,090
Spring Boot,

47
00:03:53,100 --> 00:03:59,680
internally you are using Spring MVC framework. That's  the Spring web MVC framework.

48
00:03:59,690 --> 00:04:04,820
Why do we need Spring Boot? That we have talked a lot about in this specific course.

49
00:04:04,890 --> 00:04:08,590
So in the last few steps we saw the need for Spring Boot, right?

50
00:04:08,600 --> 00:04:10,890
We don't want to be configuring things like that.

51
00:04:10,900 --> 00:04:15,230
We are configuring views resolver, we configuring dispatcher servlet.

52
00:04:15,350 --> 00:04:22,280
If we're using Hibernate JPA we need to configure datasource, entity manager and transaction manager

53
00:04:22,310 --> 00:04:24,300
and lot of that kind of stuff.

54
00:04:24,440 --> 00:04:25,840
Spring Boot says, OK!

55
00:04:25,850 --> 00:04:27,830
Why do you need to do all this configuration?

56
00:04:27,830 --> 00:04:30,000
Can we really think different?

57
00:04:30,020 --> 00:04:32,230
The thinking of Spring Boot is, OK!

58
00:04:32,450 --> 00:04:38,600
This guy has added a Spring MVC jar, so can I configure some of the beans automatically? Can I

59
00:04:38,600 --> 00:04:43,310
configure a dispatcher servlet automatically for you? Can I configure  view resolver automatically

60
00:04:43,310 --> 00:04:44,140
for you?

61
00:04:44,140 --> 00:04:45,800
Can I configure a data source.

62
00:04:45,830 --> 00:04:51,520
If the hibernate jar is on the classpath. I know, he put Hibernate jar in the class because he wants

63
00:04:51,540 --> 00:04:58,350
to talk to database. Why don't I automatically create a datasource? So thats what Spring Boot does. The auto configuration

64
00:04:58,360 --> 00:05:05,240
part. It looks at frameworks which are available on the classpath and provide automatic configuration. This

65
00:05:05,240 --> 00:05:08,960
starter projects are all built around well known patterns.

66
00:05:09,030 --> 00:05:14,670
We will talk about Spring Boot starter web and Spring Boot starter JPA in the next step.

67
00:05:14,670 --> 00:05:21,730
Other than starters the important goals of Spring Boot is to provide a few monitoring features.

68
00:05:21,870 --> 00:05:27,480
So it also provides starters like Spring Boot starter actuator which is used for monitoring.

69
00:05:27,480 --> 00:05:34,510
So it enables monitoring for you application and also it has starters to pick different embedded servlet

70
00:05:34,530 --> 00:05:41,250
containers. And it has starters for logging so if you want to use log4J, there's a separate logging

71
00:05:41,250 --> 00:05:42,800
for it as well.

72
00:05:42,840 --> 00:05:50,310
I hope this video helped you to understand the difference between Spring, Spring MVC and Spring Boot.

73
00:05:50,310 --> 00:05:52,840
In the next step, we would focus on

74
00:05:53,030 --> 00:05:53,400
starters.

