Spring Boot Fundamentals: Creating a Spring MVC App | ChargeAhead LLC | Skillshare

Playback Speed

  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Spring Boot Fundamentals: Creating a Spring MVC App

teacher avatar ChargeAhead LLC, Technologist

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

11 Lessons (27m)
    • 1. Course Overview

    • 2. Course Roadmap

    • 3. Audience

    • 4. Prerequisites

    • 5. Tools

    • 6. Demo: Creating Model, Service and Controller layers

    • 7. Demo: Adding View layer using Thymeleaf

    • 8. Spring Boot Developer Tools

    • 9. Demo: Spring Boot Developer Tools

    • 10. Demo: Adding and referencing external javascript and css files

    • 11. Summary

  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.





About This Class

In this course we will build a fully functional Spring MVC app for managing item inventory. We will implement the model, service,controller and view layers to show the items inventory. We will use thymeleaf for the view layer. We will explain how to integrate third party libraries like jquery, bootstrap etc in our app and refer to thymeleaf model attributes in the view layer. We will also introduce Spring Boot Dev Tools which makes development and testing easier.

Meet Your Teacher

Teacher Profile Image

ChargeAhead LLC



Class Ratings

Expectations Met?
  • Exceeded!
  • Yes
  • Somewhat
  • Not really
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.


1. Course Overview: spring book configures the app to be a spring embassy app, with just one dependency doing all the heavy lifting in order configuration. Hello, my name is Bunker Jane and welcome to this cores Springwood Fundamentals. Creating a spring NBC app in this course will first start off talking about Horwood right audience for the scores. Tools needed to follow along and prerequisite were most successful with scores. We will create a spring embassy app with all the layers the model service controller and the view. Layers will use time leave template engine for the view layer and under standards, usage time Leaf is one of the temperate engines supported by spring boot. We'll learn how to integrate third party libraries like J. Query Bootstrap except Ruin our APP. See Spring boot Developer Tools in Action, which makes developing and testing easy. Here is how our app is going to look after we're done, adding the videos NBC layers. The view layer is built using time leaf style with bootstrap, where we're seeing a list of items. The view layer is integrated with the controller service and model layers to bring us back this data. All right, let's get started building this 2. Course Roadmap: I plan to create a series of courses covering the various aspects Offspring boot and wanted to take a moment to go where the courts roadmap to let him know what is coming and what we will cover in each course. The full scores, springboard fundamentals, basics and getting started. We will introduce spring boot, cover its fundamental concepts, and we'll get started developing applications. We will see how to use spring initialize er rapidly build and run a simple Weber first and then a console application in the next course spring. Good fundamentals Creating a spring embassy app will build a fully functional spring, NBC App for Managing Item Elementary. We will implement the model service controller and view layers to show the items in wintry really use timely for the view layer. We will explain how to integrate third body libraries like Jake Witty, bootstrap, acceptable in our application and refer good model attributes in the view Earlier will also introduce Springboard Death Tools, which makes development investing easy in the next course springboard fundamentals. Connecting to read a base will continue building over AB and corrected toe a back end database using Springer the GP repositories. We'll start with anonymity, database H two and then later switched to my sequel to show how springboard makes it easy to work with religious databases and switch them at ease will create the ad update, delete operations and complete our spring Embassy AB. Creating timely views for adding in the leading along the way will further explore time. Leave template engine In the next course. Springboard fundamentals. Building and consuming arrest based Web services will demonstrate how spring boot makes it easy to create and consume rest services. We will create great dressed endpoints for the items in that invent tree. We'll then see how to consume rest FBI's In our springboard project. We will take the Web layer off our spring remesy app built earlier, and it sort of fetching data from Madrid. Abi's will display the front end consume later from the rest FBI's In the next course Springboard fundamentals. Monitoring health and metrics with actuators will demonstrate springboard actuators. Detroit is a lot of useful health endpoints and metrics right out of the box with zero according, we will show how to expose and enable the health endpoints. We'll see how to implement our own custom health checks and create new endpoints in the course Springboard fundamentals. Improving performance by implementing cashing, we will demonstrate the cashing support. Springboard provides with just a dependency and a few annotations who can be wise and effective cashing strategy for the application. We will first demonstrate the cashing with the fourth cash manager Springwood provides, and the later sparked the provider to read this in the course Springboard fundamentals. Implementing security. We'll see how springboard makes it easy to implement security. Well first demonstrated basic authentication. Well, then switch over App to use Didem is authentication. Springboard actuator Security is now integrated with the main apse security. We'll see how to predict actuator endpoints. We want to talk about the or to support in the course spring. Good fundamentals are configuration with profiles and deployment. Using docker, we will see how to configure or app for different environments like Devon Prawer using spring for files. We'll also see Holder Doc arise our application docker containers provide consistent development, build test and production environments and make running and deploying our APS very easy. I would recommend taking these courses in order, but if your family, with a certain aspect of string boot. You must skip that course and more to the next one. Further, if you just want to take the course for a certain aspect, it should be self sufficient to explain the concept without necessarily having to take the previous ones, though I will always recommend great the previous courses for a better understanding. So following these cities, of course, is you would have a solid conceptual, and it's turning off. The various aspects of this framework rapidly start developing applications and micro services. All right, let's not talk about the audience for the scores. 3. Audience: This course would be useful for Java and spring developers who want to understand spring boot and also for sort for architects who want to understand this powerful free work and how they should apply to their applications. What are the prerequisites to be most successful with scores? 4. Prerequisites: there are not a whole lot of produces its for the scores. The only thing you need is some basic Java knowledge and some basic spring concepts. Even if you do not have a lot of family already with these, don't worry. I will try to explain the concepts along the way, and you should be able to follow along without much difficulty. Let's next talk about the tools you will need to follow this course. 5. Tools: we will have a lot of demos in the scores as a believe that is the best way to learn the tools I would using. The scores are off course. Jama. I would be using open Judy Kay Warren, 11 but you can feel free to use Java or open Judy Kay versions eight or above, and most of examples should work for the i. D. E. I would be using Sprinkle Sweet, which is a flavor of eclipse but is highly customized and optimized for spring development . I would be using the version for it is open source and free and comes with a lot of bells and whistles. But I think you would like, however, if your family with and we like to use some other I d like intelligent etcetera, please feel free to do so. We will use spring boot version 2.1 point four. You can find the cold for the demos in the scores and the falling good Have you are 6. Demo: Creating Model, Service and Controller layers: in this demo, it will start building or spring in the sea. App for managing the Item Elementary. I will add the Web and Time Live dependencies tour app. Next, it will create the model layer for the items object. Next, we will create a service layer where they get all mature. Richard return a starting list off items in our next course. We were lingered over the database to fetch the list. From next, we will create a new controller for our items. Let's create a new project by going to file new other spring boot Spring Starter project. That's Nimet Spring, NBC. Keep the bill as maven packaging as Jar. Let's change the job award in 2 11 Let's get the rest of the defaults for the aunt Effect on version I D. Click next. Let's Search for Web and it. Let's all the search for time Leaf and added Click finish. Now here's what project with the familiar maven structure here is the bomb file will see your dependencies for time Leaf and Web. The spring boots started. Rep. Dependency will make spring boot most of the spring and visit configuration for us. Here is our main application class where we see the art springboard application. A notation. All right, let's start by adding the more later or app tohave clean separation that we create a model package first. So right click on the mean package. No choose new package. I'm creating it as comrade example. Don't damage that model. I like to keep my main class with the and springboard application in the suit and then creates up packages and the red to keep other layers in. The advantage of this approach is that you do not have to configure app to scan for components in these additional packages as but afford. Spring Booed would scan the package of the main class and also packages under it. However, spring Boot Reuters mechanism to create different Bacchus structures and include them for scanning. For instance, if your creature packages like my package, my package to then you will have to use the add components can invitation in your main class, and then you can specify the package names comma separated. So I prefer the approach of creating the other components under the main package and sub packages. All right now, right click on the package and choose new glass. Call it items our items would have feels integer. Item i d. String item name Double that in price. An integer item. Quantity That's right. Click and choose Source. Generate and getters and sitter's Let's have our class implement serialize able imported at a default serial order. New I d. Next wreck, Click and choose source. Generate constructor using fields. Next, let's add this service package by right clicking and choosing new package and put it under comrade. Example that demo. Now right. Click on this package and choose new Class and call it items service. The service class will be called from the controller. That's market with the art service. In addition, imported let's create a method. Richard owns a list of items. Call it, get all inside. We create an A realist off items, fill it with some items and return it in the next course. We will have it first. The list from Madrid agrees. Let's fix the imports. Jews, Java. Don't you do a lot list now on to our controller layer. Let's right. Click on the main package and choose new package. Call it comrade example there, Dammit! Controller, Click Finish now let's create a new class but right, clicking on the package and choosing new glass college items controller Let's give it the controller and notation with that request mapping. Give it a base. Mapping off inventory inside the class lets out a where the items service class fix the imports. Now it advocates mapping. Let's map the slash all and slash So both falling the slashing of entry to the falling method, which returns a string. Let us name it and get all it takes in the model parameter Spring will inject this at runtime. Inside, let's get a list of items in the items variable using other item service. Don't get all method, not were model. Let's add it as an attribute with the name items and the value as items. Let's add another attribute heading and call it my heading. Both of these attributes really passed on to our view layer finally buried in our time leave you name, item view fixed the imports twos Jamari It'll not list and other items object we have now all the layers in place except of you layer that's building next 7. Demo: Adding View layer using Thymeleaf: In this demo, we will create a timely of template. Display the list of items Time leave expects the templates to be present in the source. Main Resources Templates folder. So let's click on this folder and choose new other Web and then html file. Let's give it the same name as we're turning In our view, I don't know you don't HTML First, let me add the time. Leave name space to the HTML Lord with prefix th inside the body. Let's start our Dev next or display items. Let's create a table, have a header row and in the tip of body let us it read over the rose. So inside the TR tax using time you've name space th colon each we trade. Grab the current item in the item variable from the items attributes we added to our model using the special Centex Off dollar sign and then the variable name in curly braces. Now, from the retrieved item for the attrition, we display inside the TD the value using the same Centex and going a level down using items dot item I d and so on timely district. So let's close the tax that is it. There is no see your up in action. So from the boot dashboard, let me run it. Go to the browser. Let's go to Easter DP local host, a deity slash and wintry and we see our list of items. So our spring embassy layer is fully functional with all its layers, and we had to do no embassy configuration except writing our custom code. How cool is that? I think it would be nice to have a header, so let's go back to our controller. We had already Boston attribute for the name of heading in the page, using each one that it's pretty heading. We're treating it from our model. So inside each one report the span tag and using Tyler's name space th Colin text really treated using the special syntax of dollar sign on the available name in curly braces. So let's go back to our controller. We had already Boston attribute for the name of heading. Let's change the value to invent Tree. Let's restart over app to see the trainers. Yes, we do see the new heading now not toward the development process. You will keep adding things, making changes, but it is not convenient to keep starting on app to see the changes. That is where spring boot of labor tools can help. Let's see how. 8. Spring Boot Developer Tools: the spring Good of Labor Tools Module makes Developing with spring boot a true pleasure. You do not have to worry about restarting or ab every time you make a change. It is a dependency spring. Buddha have tools, but you need to add to your project dependency, and that is all we have to do. Spring boot takes care of the rest. Automatic restart is an important feature of the tools. Whenever you make a court change, deaf tools causes an automatic restart of the AMP. When it sees a file on the class part, change this Can Freud. The developers are fast feedback to the change they're making. Spring boot provides to class loaders the classes, which won't change that. The third party jars are loaded using a base class loader, and the application court is loaded using a restart class loader. So an application court has changed. Only the restart last order is started knew it causes the restarts to be much faster. The started resources, like the CSS files and templates etcetera, do not need a restart. Deaf tools also includes a lively Lord server that can be used to automatically refresh the browser. When a file has changed. Brother extensions are available for chrome, Firefox and safari. However, if you add a new dependency in your poem file, then you do manly need to restart the APP for the change to take effect. We do not want they have tools to be enabled in production. Have labour tools are automatically disabled on running a fully Pakistan application. If your application is launched from Java hyphen jar or if it is started from a special class loader, then it is considered a production application. However, if this does not apply, for instance, if you're running it from a container, then said the system property happened, the spring don't have tools, not restart for the neighbor equals o falls to exclude it. So as I mentioned before, you can include F tools for me even as follows and monitored as optional, which is the best practice that prevents deaf tools from being transitive. Li applied to other models that user project and here it is for riddle. All right, now let's see it in action 9. Demo: Spring Boot Developer Tools: in this demo, we will add depth due to our app and see you to use in the development process. Let us first stopover app. Let's add a dependency by right clicking on the project choosing maven and then our dependency type day entered searches for the dependency hair press okay and that is added to her palm file goingto upon file, we see the dependency here. We can also added Manly if you want to. Let's right click on our Project Jews Maven and then Update project that has started the app Here in the console, we see that there is also a lively Lord server started. Let's say I want to change the heading to my INR entry. Let's make the change and as soon as they say the change, you can see their tools, sees the change and restart incrementally deploying the changes Go to the browser refresh and we see the new heading over there. Now, as we saw, there was a lively lord. So what started with the death tools? Now several browsers, like chrome Firefox safari, also have lively Lord extensions, which would automatically refresh the page when it changes may toe a nap even though having this extension is not necessary, you can simply refers to pay yourself. But it is nice and makes development even easier. So here I have Firefox running. Let me go to the menu and go to the extensions page over here. Let me search for live Reload. Let's choose this extension added Do Firefox. And now it appears, Over here, let's click it to enable int No, I have stacked my browser and the console. That's where you can see simultaneously that as I make a change to my code, they have tools fill in, criminally deployed. The browser will protect and will refresh it automatically. All right, let's change the heading now to item in wintry. Let me see of the change. Deaf tools kicks in and incrementally deploys it. And as you can see, the browser refreshes automatically and I can see the new heading over here. Pretty cool, isn't it? All right. Next, let us prove subspace with a little bit off bootstrap, and see how to include external jars in our app. 10. Demo: Adding and referencing external javascript and css files: in this demo, we will see how to make our webpage look pretty and responsive with. Bootstrap will see the Raiders ways off refering to external JavaScript and CSS files another page using links, refering to see the ends or content delivery networks hosting them, downloading the jars on star tickly, referring to them or using Web jars and using me even to manage the jars for us. They should be exciting. So let's get on with it. First, let me google bootstrap, and it brings me to boot straps. Website. Bootstrap is worlds most popular front and component. Lavery. Let's click on Get Started, Scroll down To start her template, Let's copy the major tax for Car Said and Vieux Port, as well as a Cdn link for books. Traps here says, and paste it in our file. Go back to the bootstrap page and the starter template, and let's copy the JavaScript files for Jake Pretty popular and books draft from hair and piss them in the bottom off our webpage bootstrap voice on the 12 rate system. Typically, you would have an ultra class, which will be container or containers fluid continued fluid covered. The entire worked So let us give our day of the class of container. Let me give the scoop off er to row and off each column to call. Let's do this for the table body also. Lastly, let me add to the table the bootstrap classes, table and tables, right? All right, let's save it. Started her application. Go to the browser type and extra TV. Local host 80 80 slash inventory and our page looks much better. Now let's see how to refer the jars statically so spring boodle automatically are starting their resources, located within any of the following the victories. Slash murder m slash resources slash resources slash static flash public to keep a clear demarcation, let me add under static, a folder for CS says and and another folder for JavaScript fights. I have downloaded the files and let me paste the CSS file in the CSS for her and the JavaScript files in the JavaScript folder. Going back to our webpage, let me add type equal to text, slash CSS and now refer to the CSS file, using each ref pointing under static so slash CSS and then over bootstraps. CS is finally simply for our scripts let me add type equal to text slash JavaScript and let's refer to them using slash GS and then defined name. I have made the changes for all three JavaScript files. You can similarly place your custom CSS and Js files in these folders and refer them. Similarly, let's go to our browser, clear the cache and refresh your page again, and it still works fine. Finally, let us look at Web jars with you and the Web, John Dependency to your Palm file So maven will download and manage it for you if you go to a Web Genser arc. There are Web jars for most popular frameworks like J. Query, Bootstrap, etcetera. You can grab the mayor dependencies for them. I have already copied and pasted the dependencies for Jake Worry, Papa and Bootstrap. Let me right click on the project. She was maven and then update. If you expand Muren dependencies and scroll down, you would CJ query bootstrap ex cetera. Let's expand bootstrap under meta M Resources Web jars. Bootstrap 4.3 point one. You would see CSS folder, where there are CSS files and a James Fuller where there are Js fights. Let's go toe boots. Traveler Min Norcia says. Right? Click and choose Copy Qualifier. Name good words. TIM will file business in this source. They move everything in front until you reach slash Web jars. Let's do it similarly for the JavaScript files for J. Query Proper and books Rafael. Now, since we have added the dependencies toe maven, we will have a restart our application. Let's go to the browser, refresh your page and works just fine. We have reached to an end of this course. Let's summarize what we talked about. 11. Summary: in this course, we started off talking about the audience tools and prerequisites for the scores. Next, we created a new spring starter project where we added the model service and controller layers for our items object. We used time leave to create the view layer and along the way I learned how to work The time Leave springboard of labor tools helps us incrementally deploy application as you make changes without us having to return the APP, the only time we have a restart is when we add a new member independency. This can help speed up the development process significantly. Next, we applied bootstrap to our webpage and also saw the radios ways off, including external libraries to our Springwood app. I hope you got a good honest turning off building a springing missy app with the readers layers and using time leave as a temperate engine. Thanks for watching and see you next time