Introduction to the

Spring has been the de facto J2EE standard since its inception. Spring, as a lightweight J2EE application framework, was designed for the complex features of EJBs, and there is no doubt that Spring won the day with its simplicity, understandability, and usability.

Spring continues to evolve from the initial XML configuration to the later annotation configuration, but is there, is there a way to run Spring applications without configuration? Spring Boot was born.

For more, visit www.flydean.com

SpringBoot is a new, open source, lightweight framework that the Pivotal team began developing in 2013 and released its first release in April 2014.

Spring Boot makes your enterprise applications easier to write and easier to run. And the integration of a lot of common third-party lib libraries, you do not need to manually reference configuration trouble.

Running the most complex Spring application with the simplest configuration should be the ultimate goal of Spring Boot.

At the same time, Spring Boot as far as possible to get rid of XML configuration, can provide independent operation, server internal operation and other running modes, convenient for us to use.

Basic Operations of Spring Boot

The latest Spring Boot version is 2.3.0.RELEASE, which requires at least JDK8 support and Spring Framework 5.2.6.release.

In terms of build tools, you need Maven 3.3+ and Gradle 6.3+.

On the server side, Spring Boot has three built-in servers: Tomcat 9.0, Jetty 9.4, and Undertow 2.0. Spring Boot needs to be deployed in a Servlet 3.1+ environment to work.

In terms of installation, There are two ways to install Spring Boot. The first way is to introduce it in the form of JAR package in Maven or Gradle. The advantage of this way is intuitive, and the configuration of Spring Boot can be seen in the project.

The second is to use the Spring Boot CLI, which also lets you run Groovy scripts.

Here are some of the basic modules in Spring Boot:

The following list of tutorial files, you can step by step to reference to run, run I believe you will have a deep understanding of Spring Boot.

  • Build your first application using Spring Boot
  • How do I change the default port in Spring Boot
  • Introduction to Spring Boot Starters
  • Spring Boot custom parent POM
  • Use Spring Boot to create a fat JAR APP
  • Comparison of spring Boot running applications with Maven versus fat JAR/WAR
  • Spring Boot annotations
  • The difference between Spring Boot @enableAutoConfiguration and @Configuration
  • Customize spring Boot automatic configuration
  • Configure the Web app in Spring Boot
  • Migrating from Spring to Spring Boot
  • Properties in Spring Boot
  • SpringBoot @ ConfigurationProperties explanation
  • Load the initialization data in Spring Boot
  • Exit code of Spring Boot
  • Shutdown SpringBoot App
  • Spring Boot custom banner
  • Spring Boot filter
  • Spring Boot uses @jsonComponent
  • Spring Boot internationalization support

Build and deploy Spring Boot

Maven or Gradle is often used to develop Java projects. Perhaps Maven is more commonly used than Gradle. To use Maven, it is necessary to install Maven. What if some users do not want to install Maven? Or if the user does not want to install Maven globally, the project level Maven Wrapper can be used to do this.

If you use IntelliJ IDEA to develop a Spring Boot project, the Maven Wrapper will be automatically applied to the project if you choose to create the project from Spring Initializr. In short, there will be two more files under the project directory: MVNW and mvnw.cmd.

  • Introduction of Maven Wrapper

Once we’ve created the Spring Boot application, how do we run it in the build environment? Running the program as a raw Java-JAR does not guarantee the robustness and stability of the program, and it is best to register the program as a service.

  • Register the Spring Boot application as a system service

Spring Boot tools

Since the first release of Spring Boot, Spring Boot provides a range of production-level features for Monitoring applications, collecting metadata, and running or database status.

Spring Boot allows you to use these features directly without having to implement them yourself; it uses HTTP or JMX to interact with the outside world.

  • Spring Boot Actuator

Spring Boot provides us with a convenient environment for developing Spring Boot applications, and in order to facilitate our development of Spring Boot applications, Spring Boot has introduced the Spring Boot DevTool to help you develop and test Your Spring Boot applications more quickly.

  • Use of Spring Boot DevTool

We talked about The Actuator of Spring Boot earlier. But Spring Boot only provides interfaces that need to be integrated into the monitor. Today we’re going to talk about a great monitoring tool, Spring Boot Admin. It uses a graphical interface to make our Spring Boot management easier.

  • Use Spring Boot Admin

Spring Boot tests

Testing is a necessary feature of an application to ensure its robustness and stability, especially in a CI environment.

Spring Boot has a special spring-boot-starter test, which can be easily used to test in Spring Boot.

  • Testing in Spring Boot
  • Spring Boot TestRestTemplate is used

JPA is used in Spring Boot

Spring Data JPA is an implementation of the Java Persistence API (JPA), which is a standard for storage apis, allowing easy access to data. The dao layer interface is written according to the convention naming rules, so that the access and operation of the database can be realized without implementing the interface. It also provides many functions other than CRUD, such as paging, sorting, complex queries, and so on.

Spring Data JPA can be seen as a secondary encapsulation of Hibernate. Using JPA in Spring Boot is very convenient.

  • Spring Boot: Introduction to Spring Data JPA
  • Java 8 applications in Spring Boot JPA
  • The use of Spring Data annotations in Spring Boot
  • Use the H2 in-memory database in Spring Boot
  • Use an in-memory database in Spring Boot
  • Spring Boot JPA uses @Entity and @Table
  • Spring Boot JPA query statements
  • Use of associated tables in Spring Boot JPA
  • Use of Transaction in Spring Boot JPA

Integration of Spring Boot with third-party systems

Spring Boot has integrated a number of third-party services for developer convenience, and we can use them directly.

Even if Spring does not officially provide integration, the third-party systems themselves provide integration with Spring because Spring is so widely used.

  • Swagger CodeGen is used in Spring Boot to generate a REST Client

conclusion

This article will continue to update Spring Boot 2.x related articles, you feel good can point a concern, at the same time, if you have suggestions for the tutorial content, welcome to leave a reply, I will try to complete, thank you for your support!

In this article: The Flydean program

Link to this article: www.flydean.com/learn-sprin…

Source: Flydean’s blog

Welcome to pay attention to my public number: procedures those things, more wonderful waiting for you!