• Professional Development
  • Medicine & Nursing
  • Arts & Crafts
  • Health & Wellbeing
  • Personal Development

Course Images

Getting Started with Spring Boot 2

Getting Started with Spring Boot 2

  • 30 Day Money Back Guarantee
  • Completion Certificate
  • 24/7 Technical Support

Highlights

  • On-Demand course

  • 12 hours 56 minutes

  • All levels

Description

Learn how to build real-world applications using Spring Framework 5 and Spring Boot 2

This course offers hands-on experience building Spring Framework applications using Spring Boot. The first thing that is going to stand out is that we are going to move away from the boring, non-useful demos. In the new course, we are going to build a practical application from start to finish. While we are creating this application together, we will take a look at some of the new features Spring Framework 5 & Spring Boot 2 have to offer. By taking this course you will have the latest skills that you need to build real applications using the Spring Framework. What is Spring Boot?
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". Spring Boot takes an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration. Spring Boot is the starting point for building all Spring-based applications. Spring Boot is designed to get you up and running as quickly as possible, with a minimal upfront configuration of Spring.
- The new features in Spring Boot 2 & Spring Framework 5
- Spring MVC
- SPring Security & Thymeleaf
- Spring Data JPA
- Spring Boot Essentials
Gain hands-on experience building Spring Framework applications using Spring Boot 2

What You Will Learn

Get started in seconds using Spring Initializr
Build anything - REST API, WebSocket, Web, Streaming, Tasks, and more
Simplified Security
Rich support for SQL and NoSQL
Embedded runtime support - Tomcat, Jetty, and Undertow
Developer productivity tools such as live reload and auto restart
Curated dependencies that just work
Production-ready features such as tracing, metrics and health status
Works in your favorite IDE - Spring Tool Suite, IntelliJ IDEA and NetBeans

Audience

Java Developer - You should be familiar with the Java Programming language. You don't need to be a rockstar (I certainly am not) but you should have an intermediate understanding.
Web Developer - While you don't need to know Spring to get started you should have some experience building web applications. If you have experience using another MVC framework that's even better but it's not required.
Heard of Spring - You don't need prior experience with Spring but if you have at least heard of it and understand what it is that will help you out. You are interested in seeing some of the new features in Spring Framework 5 and Spring Boot 2.

Approach

This course takes a hands-on approach by guiding you in building a real-world application. You will learn core concepts and features as well as understand each step in detail as you build the project along with the instructor. By the end of the course, you will be able to deploy your product to a production server.

Key Features

Learn the latest techniques for building Spring MVC applications using Spring Boot 2 * Build a real-world project * Learn how to deploy your project into production

Github Repo

https://github.com/packtpublishing/getting-started-with-spring-boot-2

About the Author
Dan Vega

Dan Vega is a Software Engineer living just outside of one of his favorite places in the world, Cleveland, Ohio He is a self-taught programmer who firmly believes that you can accomplish anything in this life if you put your mind to it, roll up your sleeves and are willing to put in the work. Dan haa been writing software for over 20+ years now uses his knowledge, passion, and influence to help other developers achieve their goals. He teach online and currently, has over 55,000 students. When Dan isn't writing software there are a number of things that really keeps him busy. He loves to read books, listen to podcasts and watch online courses. Dan has a real thirst for knowledge and it consumes him every single day of the week. He also love to run & lift heavy weights which keep him balanced throughout the week.

Course Outline

1. Introduction

1. Section Introduction

This video introduces you to the section.

2. Goals for this section

In this lesson we are going to discuss what our goals are for the section. We will define who this section is for and more importantly who this section isn't for.

3. Development Environment Setup

In this lesson we are going to make sure that we all have our development environment setup correctly.

4. Spring Framework vs Spring Boot

Many students get confused about what the Spring Framework is used for vs why we need Spring Boot. In this lesson I will try and answer those questions.

5. Section Resources Update

Keep in touch for section updates.

6. Section Documentation

Everything we are going to talk about is in the documentation.

2. Project Overview

1. Project Introduction

In this lesson we are going to talk about reddit and what we can expect to build in this section.

2. Create the initial Project

Learn to create projects.

3. Running with Spring Boot

Now that we have created our application, it's time to explore what the Spring Initializr did for us.

4. Requirements

In this lesson we are going to look at the requirements for this project.

5. Mockup the UI

In this lesson we will discuss the process for creating the templates used in this project.

6. Domain Model

In this lesson we will look at a quick domain model that I have created. This will at least give us a plan to start creating our domain model in our application.

3. GitHub

1. Introduction

Here, we are introduced to GITHUB repository - a free platform.

2. Create the initial Repository

In this lesson we are going to create the initial repository and pushing it to GitHub.

3. README Setup

In this lesson we are going to talk about creating a README file for your GitHub project.

4. Git Workflow

In this lesson we are going to discuss our branching strategy for this section. Each time that we begin to create a new feature we will create a new branch.

5. Using Git & GitHub

In the documentation I added some useful links to learn all about using Git & GitHub.

4. Spring Boot Essentials

1. Spring Boot Essentials Introduction

We are introduced to Spring Boot.

2. Spring Boot Devtools

In this lesson we are going to talk about one of my favourite essentials, Spring Boot Developer Tools. The Developer Tools help make us a more productive developer and you really should be using them in your development environment.

3. Configuration & Properties

Look into properties of Spring Boot.

4. Profiles

Profiles give us a nice clean approach to separate our configuration for different environments.

5. Debugging & Logging

In this lesson we are going to discuss debugging & logging. I think these are 2 important skills that help me become a better developer.

6. Actuator

In this lesson I am going to introduce you to the Spring Boot Actuator. We are also going to discuss what has changed from Spring Boot 1.x

5. Spring MVC: Model

1. Spring Data JPA

In this lesson we are going to introduce Spring Data JPA. What is JPA, Hibernate and how does this all fit into our application?

2. Entities

In this lesson we are going to start building our model by creating some entities.

3. Project Lombok Refactor

In this lesson we are going to refactor our entities using Project Lombok.

4. Repositories

The central interface in the Spring Data repository abstraction is Repository. In this lesson we are going to create a repository for Link and Comment.

5. Entity Relationships (Mappings)

In this lesson we are going to discuss the relationships (Mappings) between our entities.

6. Auditing Aware

Spring Data provides sophisticated support to transparently keep track of who created or changed an entity and when the change happened. To benefit from that functionality, you have to equip your entity classes with auditing metadata that can be defined either using annotations or by implementing an interface.

7. Merge Branch Back into Master

We are going to merge our model branch back into master.

6. Database Layer

1. Introduction

Here, we are introduced to Database layer and subtopics.

2. Common Application Properties & H2 Database

If you can't always remember what properties can be set in your application.properties there is a really good reference at the link below. https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

3. MySQL Settings

In the previous lesson we looked at how to use the H2 in-memory database. That is great for getting started but at some point, we will want to move to a production ready database like MySQL. If you are using some other DBMS just do a quick search for what your settings will look like.

4. Database Schema & Data

A database can be initialized in different ways depending on what your stack is. Of section, you can also do it manually, provided the database is a separate process. In this lesson we are going to look at how we can initialize the database schema and data.

5. Command Line Runner

In this lesson we are going to look at a way to initialize our database using Java and the Command Line Runner interface.

6. Explore our Repositories

In this lesson we are going to talk about how we can explore our repositories. We are also going to close out this section and merge the branch back into master.

7. Spring MVC: Controller

1. Spring MVC - What is a Controller

We are now into the C in our MVC application. The C stands for controller and you can think of the controller as the traffic cop in our application. The controller handles incoming http requests and "directs traffic". Methods in your controller are mapped to HTTP by using @RequestingMapping (or one of its composed) annotations.

2. Controller vs Rest Controller

In this lesson we are going to discuss the differences between Controller and Rest Controller. We will also take some time to discuss what the @RequestMapping annotation is and what it can do for us.

3. Controller Handler Methods

@RequestMapping handler methods have a flexible signature and can choose from a range of supported controller method arguments and return values. I have included a link to the documentation that covers all the available handler method arguments.

4. Link Controller

Now that we know a little bit more about controllers and what methods are available to us, we should be able to start building out the basic parts of our Link Controller.

5. Merge Branch Back into Master

It is time to close out this section and clean up our branch. Finally, we are going to merge our spring-MVC-controller branch into master.

8. Spring MVC: The View Layer

1. Spring MVC: View (The User Interface)

If we were creating a REST service application, we wouldn't need any view. Instead we are creating a Spring MVC app with a front end using a template engine. As we will see in a bit, we have many choices when it comes to what template engines we can use.

2. Templates

Now that we know how to serve static content, we need to understand how to serve dynamic content. This is where templates come into play and lucky for us Spring MVC supports a variety of template engines.

3. Hello, Thymeleaf!

In this lesson we are going to discuss what is needed to get started with Thymeleaf.

4. Moving our Spring-it Templates

I mentioned these towards the beginning of the section and its finally time to use them. If you missed it earlier, I created these so we wouldn't have to waste time designing some basic templates. The point of this section is to teach you all about Spring Boot, not design. If you haven't already downloaded them, please do so now.

5. Thymeleaf Layouts

In our templates, we will often want to include parts from other templates, parts like footers, headers, menu. In order to do this, Thymeleaf needs us to define these parts, "fragments", for inclusion, which can be done using the th:fragment attribute.

6. List Links (Home)

Now that we have our layout it's time to build our first page, our list of links. Before we get started it would be a good idea to have a list of links in our database. I went over to one of my favourite subreddits /r/spring boot and just grabbed 11 items for testing.

7. View Link

In this lesson we are going to build a link view page.

8. Submit Link

In this lesson we are going to build our submit link page.

9. Conclusion & Merge

In this lesson we are going to wrap up this section on Spring MVC: View. We are also going to merge this branch back into master.

9. Spring Security: Configuration

1. Spring Security Introduction

Learn more on simplified security features.

2. Configuration

In this lesson we are going to learn how to configure Spring Security. This is the start of our configuration, but this is going to be something we build on throughout the section.

3. Users & Roles

In the last lesson we used the default user & auto generated password to test our configuration. While It was good for a quick test, we really need to implement something a little bit better. In this lesson we are going to create our User & Role entities and hook them into Spring Security.

4. User Details Service

The User Details Service is a core interface in Spring Security. In this lesson we are going to look at how we can configure our user details service.

5. Add Users & Roles to Database

Now that we have everything in place, we can add some data for us to use in our development environment. In this lesson we will add some users & roles test data.

6. Auditing Configuration

Now that we have security in place, and we have some users and roles it's time we revisit something we did a little bit earlier. Remember when we created the Auditable domain class that all our other domain classes extended? Well we have the created & last updated dates working but now it's time we tackle the user fields.

7. Actuator Security

Now that Spring Boot has backed off Security, we have a little bit of an issue with our actuator endpoints. Right now, they are all wide open, so any user can get to them. In some cases, this might be ok but in most it's probably not. Let's think about some rules that we want to incorporate for our actuator endpoints.

8. H2 Console Security

If we try and go to our H2 Console (/h2-console) we won't be able to get there. We need to do a couple of things to make this work.

10. Spring Security: The View Layer

1. Introduction

What we looked at in the last section was how to configure Spring Security. Now that we have a head start on security it's time, we integrate into our view layer.

2. Custom Login Form

In this lesson we are going to create our own custom login form.

3. Username & Password Form Parameters

When we submit a form Spring Security is expecting 2 things from us: First, the username must be present as the HTTP parameter named username and the password must be present as the HTTP parameter named password. Since our field is named "email" we just need to add one more configuration to our form login and that is usernameParameter("email")

4. Logout

When using the WebSecurityConfigurerAdapter, logout capabilities are automatically applied. The default is that accessing the URL /logout will log the user out by the following Invalidating the HTTP Session, cleaning up any RememberMe authentication that was configured, Clearing the SecurityContextHolder, Redirect to /login?logout, Similar to configuring login capabilities, however, and you also have various options to further customize your logout requirements.

5. Remember Me

Remember-me or persistent-login authentication refers to web sites being able to remember the identity of a principal between sessions.

6. Thymeleaf Spring Security Dialect

In Spring MVC environments, the Spring Security integration module works as a replacement of the Spring security taglib.

7. Who Submitted this Link?

One thing that I noticed is that we never updated the display to show who submitted the link. In this lesson we will fix this issue up on the home page and the view link page.

8. Account & Register Templates

In this lesson we are going to update the templates for Register and Profile so that they display correctly. We aren't going to make these work right now, but we do want to see them load.

9. Merge Branch Back into Master

In this lesson we are going to wrap up the Spring Security View layer and merging the security section back into master.

11. Voting

1. Up Vote & Down Vote Intro

The author introduces you to the topics covered in this section.

2. Vote Entity & Repository

The first thing we need to do to make our voting mechanism work is to set up a Vote Entity & Repository. The Entity is going to be simple and contain an id, direction and link. The direction will tell us if this record is an upvote (1) or downvote (-1).

3. Voting Controller

Now that we have a Vote Entity and Repository we can begin to work on our controller. We are going to create a new controller called VoteController and walk through what this needs to do.

4. Calling our Vote API

To make our upvote and downvote work we need to do some work on our home page. What we want to do here is add some functionality that will allow the user to click on an arrow and call our Vote Controller.

5. Security Concerns

There are a few issues with our voting mechanism that we need to fix up. In this lesson we are going to discuss what those issues are and how to fix them.

12. Comments

1. Database Loader: Add new comments

We are going to add something to our CommandLineRunner so we can add some test data into our application.

2. List Comments

Now that we have some data in our database, we need to list out the comments on our link page.

3. Add New Comment

In this lesson we are going to add the functionality to add a new comment.

13. Spring MVC: The Service Layer

1. Service Layer Introduction

Controllers are supposed to be "thin" and shouldn't contain any real business logic. The controller's job is to simply handle the request and move the user into the correct view or return the response in an API call. If that's the case, then where do we put all of our business logic? The answer is of section in the service layer. As you might have already noticed there is no S in MVC but this is one of those patterns that has become standard over the years

2. User Service

Now that we know what logic should go in a service class it's time to build one. We are going to build out a simple user service class and talk about what else might go in this class.

3. Link Controller Refactoring

Now that we understand how to build services, we need to start refactoring our controllers to use them. In this lesson we are going to refactor the Link Controller and create a Link Service.

4. Exercise: Comment & Vote Services

Look into the exercise files.

5. @Transactional

The first question we need to answer is: What is a transaction? I think the best way to answer that question is to look at an example. In this lesson we will answer this question and cover how to use Transactions in Spring Boot.

6. Merge & Conclusion

In this lesson we will merge in our changes and close out this section.

14. Registration

1. Registration Introduction

The only way we must get new users into our system as of now is to programmatically add them in our Command Line Runner. Earlier in this section we updated the registration template but didn't really do anything with it. It is time we revisit that template and make it work

2. User Refactoring

One of the major problems I have with this application is that we are displaying the users email address next to link or comment. We wouldn't ever want to show a user's email address to the public like this and we need to fix it.

3. Registration Form

In this lesson we are going to build out the UI for the registration form.

4. User Registration

Create user registration form.

5. Password & Password Confirmation

There is currently now built in validator to ask if our passwords match, so we need to create our own validator. Lucky for us the validation system is very flexible and allows us to create our own custom validations and annotations.

6. Registration Process Outline

At this point we have given the users the ability to self-register, but this isn't the end of the registration process. We have several steps that are going to happen here, and I just want to make sure we understand them.

7. Local Email Server Setup

We know that part of registration process is going to involve sending some emails to the user. To test those emails out we need a local email server running. In this lesson we are going to setup one of my favourites.

8. Mail Service

Now that we know we can view emails locally we need to create our mail service that is going to send the emails. The first thing we need to do is add the spring-boot-starter-mail dependency to our pom.xml. This is something you can choose when you're creating the project but if you decide you need it later you can just add this in.

9. Email Templates

Now that we can send email, we need some templates. We can create a new folder under templates called email and create our templates there. The nice thing about these templates is they can also use Thymeleaf and nothing we are doing here should look new. The only difference is that we usually pass data down from a controller but in this case our mail service class is passing an instance of User into our templates.

10. Activation Process

Now that we can successfully send the user an activation email, we need to handle when the click on the activation link. The first thing we need to do is to create a service class method and repository method to look up a user by email and activation code.

11. Merge & Conclusion

In this lesson we are going to merge the registration branch and talk about what we did in this section.

15. Production Deployment

1. Production Introduction

The author introduces you to the topics covered in this section.

2. AWS Overview

Amazon Web Services (AWS) is a secure cloud services platform, offering compute power, database storage, content delivery and other functionality to help businesses scale and grow.

3. Spring Boot Maven Plugin

The Spring Boot Maven Plugin provides Spring Boot support in Maven, letting you package executable jar or war archives and run an application "in-place". To use it, you must use Maven 3.2 (or later).

4. Elastic Beanstalk

To get started we are going to create a new web application. Make sure you select Java as the platform and not tomcat. You would choose Tomcat if you wanted to deploy a WAR to Tomcat.

5. Production Database

In this lesson we are going to run a quick test to make sure we can connect to our production database.

6. Profiles

Now that we have a dev and production environment to think about, we need to talk about profiles. Profiles will allow us to use common properties between environments and at the same time separate out properties that only belong to a single environment.

7. Package & Redploy

At this point we should be able to repackage our application and run it, but we still have a couple issues. When I first did this, I have to tell you the logs were very helpful in determining what the issues were.

8. Custom Domain Name

In this lesson we are going to assign a custom domain name to your application.

9. WE ARE LIVE!

We have made it to the greatest place on earth, production!

Course Content

  1. Getting Started with Spring Boot 2

About The Provider

Packt
Packt
Birmingham
Founded in 2004 in Birmingham, UK, Packt’s mission is to help the world put software to work in new ways, through the delivery of effective learning and i...
Read more about Packt

Tags

Reviews