Spring Boot Fundamentals: Basics & Getting Started | ChargeAhead LLC | Skillshare

Spring Boot Fundamentals: Basics & Getting Started

ChargeAhead LLC, Technologist

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
15 Lessons (36m) View My Notes
    • 1. Course Overview

      2:42
    • 2. Roadmap

      4:45
    • 3. Audience

      0:17
    • 4. Prerequisites

      0:23
    • 5. Tools

      1:06
    • 6. What is Spring Boot?

      0:56
    • 7. Benefits

      3:33
    • 8. Demo: Spring Initialize and building our first app

      6:58
    • 9. Spring Boot Basic Concepts

      2:25
    • 10. Demo: Spring Boot Annotations and Artifacts

      2:06
    • 11. Demo: Spring Boot Autoconfiguration report

      2:15
    • 12. Demo: Running from the Command Line

      1:21
    • 13. Demo: Creating a Console App using Spring Starter Project in Spring Tool Suite

      3:14
    • 14. Demo: Bootstrapping our project using Spring Boot Command Line Interface

      1:53
    • 15. Summary

      1:53

About This Class

Spring Boot is one of the most popular open source java frameworks, which allows us to rapidly building applications and microservices. In this course, we will start from scratch and cover the fundamental concepts of this powerful framerwork. We will use the Spring Initializr to quickly build a web application first and then a console application. We we will also demonstrate the use of Spring Boot Command Line Interface. This course should provide you the basic concepts and understanding of Spring Boot and make you comfortable getting started with it.

Transcripts

1. Course Overview: spring boot is fast becoming the framework of choice for Java developers. It allows for Robert development of production, ready applications and micro services with minimal. According Spring Boot takes the convention over configuration approach and auto configures most of her application with intelligent defaults, giving us a production ready application, which weaken Just run. Hello, my name is Bunker Jane and welcome to the scores on spring boot fundamentals, Basics and getting started in this goals will start from scratch. Cover the fundamentals offspring boot and build our first Web app, and then a console app took over the readers aspects of spring boot well, first start off talking about who would with right audience for the scores, tools needed to follow along and prerequisites to be most successful with scores. Next, we'll talk about water, spring boot and its benefits. Spring boot helps accelerate and facilitate application development. In this course, we will see how easy it is to get started with spring boot and the ways ways to do so. We'll start off bootstrapping were first app using spring initial Ezer and start dark spring. Nor are you a website which allows us to add the language bill system and dependencies to quickly generate. Our springboard project will show how, with minimal configuration, we can build a functioning Web in no time. Who will then observe the important springboard and auditions Spring Starter Dependencies, An auto configuration which happens behind the scenes. We will also see the embedded Tomcat in action Spring boot for words, Intelligent defaults. We should work for a majority of cases, but we will also demonstrate how easy it is to customize spring boot if you do not like the defaults. Next, we will see hydrogen right over Springwood Project using the Spring Starter Project in Spring Tool Suite. This has a direct integration with Stargardt sprint dot io and presence is the same options but allows us to do it directly from within The I D. This time will build a simple console application to show you another flavor off the application type. You can bear the spring. Finally, we'll also quickly talk about generating Springwood products using Springborg, cli or common land in the face. But end of the scores. You will have a good foundation but spring boot and will be very comfortable starting with it 2. 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 fluid off 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 Ow! RL's All right. Now let's address the question. What is spring boot and why you should learn it 6. What is Spring Boot?: spring boot is an open source Java framework, which, in my opinion, is a game changer. When it comes for developing Java applications, the guiding principle could Spring boot is convention over configuration. It is built on top of the spring framework. Spring is a great framework for building applications, but traditionally spring applications require a lot of configuration and so makes development process sometimes very complex. We need to be able to include the right dependencies, have all the configuration done and done right before the art can start up and work properly. This is where spring boot comes in. It is highly opinionated and automatically configures our application with intelligent defaults, giving you a production really application, which you can just run. All you have to worry about is a custom application code, and it does most of the plumbing for you. 7. Benefits: one of the main advantages off reason. Spring boot is the ease and speed of developing string applications. Spring Boot is highly opinionated Androids intelligent before configurations so that you get an application, which is production ready with minimal. According we're just doing some mathematicians. Spring Boot does most of the heavy lifting and out of wedding for us, providing us with a production ready application, we can run quickly. Springboard avoids writing a lot of boilerplate code and XML configuration. If you have developed the spring embassy applications before, you know homered configuration needs to be done defining beans, setting different options extra with spring boot. It also configures everything and all your right is the application code. So if you want over with an in memory database, like each to then just included in the project dependency, Spring Boot sees the relevant John in the class part and Ottoman figures the database ready to use. If you want to add initial leader to the reader base, you can create files the standard names like scheme or not sequel, greater or sequel or important sequel and spring boot picks them up automatically and runs them. Just a few examples of how spring boot makes it easy. Spring boot Integrate well with a lot of frameworks, like Spring Security Spring did a GP, a Spring embassy except RA and with open entered, started dependencies. It greatly simplifies using these configurations and building applications. Spring boot our of the box provides emitted each to be servers like Tomcat Jetty under Toe , where it runs the application that makes development, testing and deploying or applications to production so much more easier. You do not need to have a Web server to be installed and configured. All you need is Java installing the machine if you use them. Even Bill Springboard will by default, build the app with the emitted each to be server and all the dependencies as a jar and only need to run. It is just issue the command like java hyphen jar and your jar name with optionally other parameters and it is up and running, so it makes it very simple. Even though springboard is opinionated and uses intelligent falls, it doesn't get in your way. We only use a specific framework or configuration. So, for example, by the fourth it will have the image of Tomcat server borders 80 80 but you can easily override. Report was in properties. Springboard makes the balancing management very easy. Does the concept off starter dependencies in the past the work with different frameworks, year to figure or dependency? And what version of the dependency would play well with the spring version and other dependencies and will be a lot of effort to get this right? Many times there will be unexpected errors, the incompatibility and mismatch Further. If you want to upgrade the version off off a framework, you have to then again figure out the right versions off other dependencies, which will play well with it. Springboard simplifies that the spring Boutin has mapped the dependencies and versions so that it just included Pregnancy Offspring Starter Parent, which wouldn't don't map all the other 11 dependencies and their versions. We'll see a demo of that later, but that makes life so much easier for developers. All right, now it's time for us to jump and start building our first application 8. Demo: Spring Initialize and building our first app: in this demo will look exponential Ezer and standard spending a Iot, a great tool for quickly generating. Over spring. Good projects will understand the options and dependencies. It lets us choose to bootstrap. Our application will generate over first project with dependency. See how to import it in Spring Tool Suite on our custom code could create a rest endpoint for our application and finally run over application. All right, let's get started. All right, let's first go to spring Initial Ezzor at Star Dark Sprinter I owe you can choose the bill system, maybe, nor griddle. It will stick with me even to the language for your project. Java. Gotland on Groovy will choose Jumla. The version of Spring Boot will choose the 2.1 point four version for the project. Metadata. Let's select the default Group an artifact name. Click on more options. Let's give the name as Spring NBC, you can add a description for your project. It was the packaging jar or war springboard women. Blufgan build a self contained jar with all the dependent jars and an immediate Tomcat, so starting a springboard application is as easier stopping Java hyphen jar and your springboard applications your name that it launched the immediate Tomcat with your configuration. It reduces the dependency of having an external application server and to configure it to suit our needs. All the need to run our application is JAMA. Having into the self contained executable jar also helps easy deployment using docker. Or, if you want to deploy traditionally on a Web server, you can do so by choosing the option of billing it as a war. You can choose a version of Java. He will choose washing 11. Next you can are the dependencies to a project but diving here, save Web and adding it. There are a whole bunch of dependencies and technologies you can choose to integrate with their application. Click See all hear it shows you the dependencies categorized as core. For example, they have tools cash, dependencies, hit Dios, reactive EB. It's support really is template engines out of the box that time leaf free maker mustache and groove templates you cannot Security, which will wire of your application for basic security with your according it has over to support it. Support GOP A. My sequel sequel several except out of the box as well as a bunch of musical databases like Mongo db Cassandra etcetera allows to wire up your app with messaging providers like Rabbit a Patrick Africa, etcetera. It also integrates that sprinklered core cloud or to cloud task extra Clark config Our discovery routing Second breaker tracing messaging contract Pivotal Cloud Foundry. You're gonna do great aws as your services. Google Cloud platform batch meal a lap actuators extra. Just adding these dependencies would make springboard do most of the order configuration for you literally a left writing an application court, a few annotations and configuration properties, and you're up and running. Once you have towards in the dependencies, you can have their dependencies in order keys. You have just added the dependency se generate project and download a zip file with me, even based repository and necessary infrastructure to start a string boot app. Here is our downloaded that file Let's unzip it and here is a family or maven project structure. Now we will imported in spring tool suite reading Sprinkle suite is very easy. Does Google downloading tool suite go to this link and download the delivered version for your operating system Now here on the machine I have Spring tool suite version for running . Let me goto file import Under the MoveOn tab, there is an import existing women projects. Let's go to the root for a very unzipped over application. It recognizes the poem file Click Finish. And here is our app. It has the family or moving structure. Let's go to the formal XML file here. You see the spring Boots started Parent on top with this version as to part 1.4, and here is a very dependency were included as Spring Boot Starter Web. I will talk more about the starter dependencies, but let me force illustrate the point that spring boot that's most of the order configuring for us and all we ever do, for most part, is right over application code, adding, does the Springboard Starter Web. Why're that application to be a spring embassy app with no configuration or special files required on our part, Let me go to the main package nor right click and choose a new package. Call it comrade example Don't damage or controller. Let me create a new class but right, clicking and choosing new class and calling it. Hello, controller. Let me add the at Rest Controller Foundation, which marks over class as arrest. Full controller. You can fix the inboard by either hovering over the record the line and choosing the package manually. Oregon Use the shortcut key for Eclipse Control Shift Oh, which will import all the different and sees with that request. Mapping that is map slash or route to the method public spring. Say hello inside, which was simply return Hello from spring boot. That is it. That's running the springboard AB by either right clicking and choosing run as spring boot app. Our strength will suite also provides onboard dashboard. If you do not see it, you can make it appear by clicking window show view under, then from under other born dashboard. Here you will see all over spring boot abs and they can start. Stop them easily from here. Let me start over app by clicking on this start or restart button springboard a text that we have Spring Embassy app on automatically start the omitted Tomcat Listening on port Idiot e Let's go to Easter tp local host a deity and here we see our embassy controller intercepting the request and returning hello from spring boot. Our app is a spring embassy app. We can add the model view and service layers where, with zero configuration from us, spring Boot has wired and configure things behind the scenes, and we have a running app. If you have configured Spring Embassy before using XML files, there's our configuration. You know how much work it is. And here we literally just rolled over application core and spring boot. Do the rest for us. Now let's examine the important and notations and artifacts, which makes an app of spring boot app and makes the magic happen. 9. Spring Boot Basic Concepts: here in the screen shot. You're seeing the main class for our app, which we will see in the Dem. Assume it is marked with the Arab spring Good application and audition. Our spring Good Application and audition is a convenient innovation which is equal in tow, declaring at configuration aka Naval Order configuration and add components. Can innovations are configuration and notation enables Job based Configuration act enable Auto configuration enables spring boots are the configuration feature. What does a lot of behind the scenes Heavy lifting for us and auto wires and configures things for us. The are components can enables component scanning for our spring application to scan and register beans, components, services controllers, external application, spring boot by the fort. Well, it's kinda based package. The one have the main class for our app and sub packages for components. However, it also provides a mechanism to specify different packet structure for scanning the next important thing. A springboard app. Help are the starter dependencies as it so. Earlier in the Palm file, there was a spring boots started parent in the period section of the bomb. Spring books are preparing provides dependency and blood management for springboard based applications. It contains that the full version of Java to use the default versions off dependencies that spring boat uses and the default configuration off the movement plug ins so words allows you, is to specify just version of the Springboard Starter parent. And it will pull in the right versions off other dependencies. As it knows which versions of the Brennan sees play nice with each other. You do not have to specify diversions, which can be quite a pain getting them right. Then it has other sort of dependencies. For instance, we saw Spring Boots Starter Web, which will pull in all the right dependencies and jars required for a spring embassy app. There is also a springboard starter test with Brings in Jay Unit Marcato and other dependencies automatically for us, so these starters make dependency management super easy. In the plug in section, we see the springboard moving plug in but assembles all the dependencies in their jars in one self contained executable jar or war with which you can run an application in place. Let's revisit our AB and see these and additions and artifacts in the application 10. Demo: Spring Boot Annotations and Artifacts: in this demo, we will revisit our app and see the petitions and artifacts we talked about. So here is our main class under comrade example Don't Democrat package, where you see the aren't spring boot application. In addition, this class has the mean method, which we all are familiar with. The public starting ward Main method starts of the spring application context it calls the Spring Boots provided spring application don't run mattered to run over class. Next here is the Palmer XML file, where we saw the starter period and started Web and test dependencies. If you click on the dependency hierarchy, you can see that spring boot pulled in all their 11 dependencies and their versions based more starters. If you change the springboard started painting version, it will pull the appropriate versions. Based on that does. It makes dependency management so simple for us. We will see more examples off how to override defaults in spring boot, but it'll save you want to run our Tomcat at Port 80 82 so all you do is to come to the application of Properties file under Swordsman Resources. Spring Boot also supports the Amel files is real property files. If it's a prefer here, let me specify. Server dot port Notice the nice Intelligence and specified board 80 82. Just best specifying the properties. You can override so many The four sittings. That's Reese Turnover, Springwood AB And now we see Dom Card is listening on Port 80 82 going to the browser. The old girl does not work anymore. Let's change the port to 80 82 we get back. The response. Spring Book configures our app by the presence or absence of classes in our class part based on the dependencies, we have included taking intelligent defaults. We can get an idea of how Springboard Order Confederation works by creating the order configuration report by running over app in the debug more Let's see how. 11. Demo: Spring Boot Autoconfiguration report: In this demo, we will see how string would order configures based on what is included in the dependencies . What is in the class part or not? In the class part, We will run the application with the D book Don't on from Spring Tool Suite. There are several ways of doing it. You can run her app in the debug more from the command line. Using Java happen jar your project jar, followed by hyphen, hyphen, debug. We can go to the run configuration for AB by right clicking, choosing run as selecting run configurations and checking the enable debug output. Or we can simply go to application or properties file and put debug able to True. Now let's restart over application. Here you can see the console the order configuration report. It has the positive math section where it'll configure based on the dependencies we have included. So since we have the Web dependency, dis configuring dispatcher serve alert settings since Verbinnen Steeples and Jackson, it is ordered configuring Jackson and so on. Then there is a negative Matt section were based on the absence of classes or dependencies or properties. It does not configure certain things, so since we do not have any messaging dependency, it does not configure messaging. There is no data source dependency, so it does not configure that we do not have time leave dependency so it does not configure it and so on so forth. So there are a whole lot off checks and does. We can also specify exclusions for what you want specifically excluded. We have none, though, and then there are some configurations that are done unconditionally. So hopefully this demo provides some insight as to how springboard goes about order configuring itself based on various dependencies, properties, classes, etcetera. Next, let's see how to run our spring boot app as a simple, self contained jar from the command line. This is helpful for easy and simple deployments. 12. Demo: Running from the Command Line: In this demo, you will lose the movement Command package, which will packet our application into a jar file. We will then running from the command prompt. First, let's stop the application here in Spring Tool suite. Remove the debug settings from the application of properties file. If you have moving installed on their machine, you can issue the me even package command from the command line or terminal. However, I'm going to use our I d to do that. So right click on the project. Choose Run as me, even build and space. Where the goal as package based on the artifact i D and version in our Palm file, it names over Jaar as demo hyphen 0.0 dot one hyphen Snapshot. Ghajar. Let's go to the terminal to the location where the John was created. Let us run job a hyphen jar and were John filename. Our app starts go to the browser that board 80 82 and we get a response next there to see how to bootstrap a springboard app. Using the spring starter product in Spring Tool Suite 13. Demo: Creating a Console App using Spring Starter Project in Spring Tool Suite: in this demo, it will show how to bootstrap a springboard project using Spring Starter project in Sprinkle Sweet this time just to show you another flavor. Often application. We will create a simple console AMP so let's get right to it to start the project. Let's goto file new other scroll down the spring boot and then the spring started Project Flip Next and here you see the same options to choose the bill type maven or griddle packaging, John or War double version and language. You can specify the group artifact inversion description, just as you would do on the website. Click Next, and hair you can do is the springboard version. Search for dependencies or scroll down and expand and choose the dependency you want. Click next and here. Behind the scenes, it is integrated with spring initial Ezer to generate over Project Click Finish. It has the same familiar structure in the Palmer XML file. We have the starter period. It brings in Springboard Starter and start our test to simplify verbal configuration. Let's go to the main class. Let our class implement Command line Runner Imported AG unimplemented methods. The command land runner into phase has a run mattered. Spring book will automatically call the run method off all beans. Implementing this interface after the application context has been loaded. You can have multiple common land runner beans in the same application context, and these can be ordered using the order in the face or the order. In addition, so inside here there is. Put a system out Hello from console and let us print the arguments. Also, let's run this app from the boot dashboard, and here in the console, we see the output. The first are going to supplied by spring boot. That's right. Click the application Jews run as then run configuration. At a couple of arguments, Click Run on in the console will see the three arguments being printed, the 1st 1 being supplying the spring boot with package. That application is ajar by right clicking using run as may even build, put the goal as package click run. It creates a job for us in the Target folder that is. Open the terminal. Go to the folder and type Java hyphen jar our John name. Amicable off arguments. Ours one arx two and heavy. See it prints them to the console. So this is how easy it is to bootstrap our app using Sprinkle suite, which allows us to do everything from our I d. E. And this is the method I prefer. That's also quickly look. And the third way off bootstrapping a springboard project using spring boot Cumberland in the face. 14. Demo: Bootstrapping our project using Spring Boot Command Line Interface: in this demo, we will see how to get spring boot. Come on, land in the face or CLI and use it to generator. Springboard product. Springboard Sierra is good for those who are more used to the command line. You can Google spring boots here, lie and then click. The lingo were here. Reach the section where you can download the zip or guns of file based on their system. Don't load it and extracted Go to the four Better where you have extractor date and then further to the been fuller. Here you will see a spring not bad file for Windows operating system and a shell file for Linux or UNIX based systems. You should have John Deakin starred. Since I am on the linens machine, I'll type dot, slash spring in it have been have been built equal to Maven Crispus Fire Bill tool hyphen, hyphen, java hyphen version equal to 1.11 hyphen, hyphen dependencies and through it, a comma separated list of dependencies, he warned. So just for example, I'm included web and didn't have a GP over here hyphen hyphen packaging to specify the packaging as a job or a war file. And then finally the name off your zip fight my Afghan zip. As you can see, it contacts the same service at Star Dogs printer I o gets the dependencies and generates as if I for us. Now you can again unzip this imported in Sprinkles feet and work with it as we saw before. All right, with this, we have come to an end of this course. Let's summarize what we learned. 15. Summary: in this course, we started off talking about the audience tools and prerequisites needed for the scores. We then talked about what a spring boot It is one of the most popular open source Java frameworks to build spring based applications and micro services. We talked about it's benefits like ease of development, but Spring Boot doing most of the heavy lifting with order configuration. It provides an immigrant extra to be server to make it easy to test and run your applications. It also has a great integration with a lot of spring frameworks. We saw how spring Initialize ER makes it easy for us to bootstrap our spring book application, allowing us to specify the build system, Java version and a rich set of dependencies. He started by using the star dark sprinter I A website to quickly build a spring embassy app and getting it up and running with zero configuration and minimal code. We talked about the act Springboard application and audition with Does a lot of heavy lifting for us in terms off auto configuration, spring configuration on components cunning. We talked about the Spring Boots starter period but manages the dependencies and their versions and other spring boots charter dependencies, which usually simplifies the bill configuration for us. Next, we bootstrapped and ran a springboard console application using the spring Tool Sweets Spring Boots Starter Project, which has an integration with spring initialize er. Finally, we talked about Spring Bootsy Ally, which is another way off bootstrapping, a springboard application. Hopefully, the scores provide you familiarity with spring boot, helps you understand its basic concepts and an traditions, and makes you comfortable getting started with it all the best building a springboard projects and soon extend.