How to configure any bins for the spring MUC project?

Without spring boot we need to configure these bins for the spring MUC project, so this is a typical configuration okay you can develop any kind of spring image application and if you are using hibernate then you need to configure all these things now we understood that in typical spring MUC database given spring games applications requires a lot of configuration such as dispatcher servlet wave resolver Jackson data source transaction manager among many others and this is the typical configuration which we need to configure in all kind of spring MVC database projects.


If the spring image is huge then we may need to configure a few more configurations and this is a kind of you know the common thing we need to provide in all kind of spring MVC projects now let’s take a look into how spring boot auto-configures for spring MEC model wellspring boot automatically configure spring application based on the dependencies present or not present in a classpath, for example, spring boot auto-configures a dispatcher servlet.

If spring MSC jar file is present on a classpath similarly spring boot auto-configures the Jackson Jackson bin if Jackson jar is present on a classpath similarly spring boot auto-configures a data source bin if hibernate jars you know present on a classpath so in this way spring boot automatically configures all the bins you know based on the jar file or dependent dependencies present on a classpath okay just remember spring would automatically configure spring based applications based on the dependencies present or not present in a class fourth for example springboard auto-configures dispatcher servlet.

If spring MUC jar file is present in a classpath similarly for Jackson and hibernate spring-boot provides spring boot starter web library for developing web applications using Spring MVC so just remember this dependency springboard starter web dependency so this dependency we used to develop web applications using spring MSc or we can also develop a rest based application that is a restful web services application using spring EMUC and spring boot auto configuration registers and configures the dispatcher servlet automatically, therefore, we don’t need to register dispatcher servlet manually.

Let me show you how spring boot auto-configure dispatchers are right uh in spring James application so that you will understand a little more so look at here this is the student management system application this is I have developed using spring boot okay and in pow.xml I have defined different dependencies, for example, we are interested in spring boot starter web dependency well springboard starter web dependency we used to develop web applications using spring AMUC model and this spring boot starter web dependency provided by spring boot okay and spring boot internally uses spring EMUC dependencies or libraries.

Spring boot is just you know wrapper on top of spring framework and spring boot internal uses all spring framework libraries similarly we are you now focus on this spring boot starter web dependency, so this dependency provided by spring boot and this dependency internally uses spring music libraries, for example, let me go inside this dependency and there we go so if you can look at its internals here you can see it internally uses spring framework that is ping web dependency and this dependency is provided by spring MUC module similarly spring web MUC this dependency also provided by spring EMUC model.

Just remember spring boot you know provides spring boot starter web dependency and this dependency internally uses spring MUC libraries okay and whenever spring boot finds this dependency in a classpath then spring boot will automatically configure dispatch as servlet okay spring boot will automatically configure dispatcher servlet and if spring boot you know finds spring boot starter data JPEG dependency in a classpath then spring boot will automatically configure all the bins, for example, you know data source bin transaction manager bin, etc because Bing boot starter date data JPG dependency internal uses hibernate as a GPA provider hence spring boot will automatically configure all the bins that are required to connect with the database.

Just remember these dependencies are the frequent dependencies in springboard application and here is one more dependency that is spring boot starter timeline dependency if springboard finds this dependence in a classpath then springboard will automatically configure a view resolver for the timeslip template engine okay great now we pretty much understood how spring boot auto-configures you know for spring MVC model now let me show you one more important class here that is dispatcher servlet auto-configuration class, so spring boot team has basically written auto-configuration classes for different bins similarly dispatcher select auto-configuration class.

This class basically you know spring boot will execute when it finds spring boot web starter dependency in a classpath and all the auto-configuration this you know dispatcher satellite auto-configuration logic has written inside this class, for example, look at here dispatcher sublet instance is created okay and here dispatcher solid instance is registered, so this is just for dispatchers solid auto-configuration there are different auto-configuration classes provided by spring boot to configure different configurations automatically now we pretty much understood.

How to spring mode auto-configuration works for spring MVC so whenever spring boot you know finds dependencies and classpath based on the dependencies and classpath spring boot will have to configure all the required configuration for spring MUC applications all right great we’re going to build a simple student management system web application using springboard spring game you see timely spring data JPI and MySQL database all right and here are the tools and technologies that we’ll be using in this course we’re going to use java 16 which is our latest release of java as up now and make sure that you have installed Java 16 on your machine you can use java 8 l1 or you know 15 as per java installed on your machine but make sure that you use java 8 plus.

I want to use the latest release of spring boot and spring airbus and spring data GPA spring data ship internally uses hibernate as a GPA provider and we’re going to use the MySQL database to store and retrieve the data and we are going to use a timeslip template engine to you know to develop the view layer and we use eclipse STS ID all right now let’s take a look into spring boot MUC project architecture.

This is the standard architecture that we are going to follow to develop our spring boot application and this is the three tire or three-layer architecture it has a controller layer service layer a repository or a dowel here okay this is a widely used architecture in you know project development so basically controller layer holds all the spring image controllers and service layer basically holds all the service classes it has business logic and repository error down here holds all the persistence or database-related logic and repository is responsible to talk with you know MySQL database.

Leave a Comment