preface

Spring Boot is a new framework from the Pivotal team designed to simplify the initial setup and development process for new Spring applications. The framework simplifies configuration by agreeing to configuration principles. Spring Boot is committed to being a leader in the burgeoning field of rapid application development. Spring Boot is currently widely used by major Internet companies and has the following characteristics:

  1. Create a stand-alone Spring application
  2. Embedded Tomcat without the need to deploy a WAR file
  3. Simplifying Maven Configuration
  4. Automatic Spring configuration
  5. Provides production-ready functions such as metrics, health checks, and external configuration
  6. There is absolutely no code generation and no configuration required for XML

And Spring Boot can be perfectly integrated with Spring Cloud and Docker, so it is very necessary for us to learn Spring Boot. And understand its internal implementation principle. Spring Boot learning notes more than 100 pages, concern public number: Kylin bug; Not only can you learn how to use Spring Boot, but you can also learn and understand its internals!

I don’t care what she is, just use it!! But my resume says “proficient in SpringBoot”… That is generally speaking SpringBoot is what things!

You have to add your own salt, sauce and vinegar, and stir it well before you can eat it.

SpringBoot is not the same, directly for you to come over a bowl of fragrant beef ramen, wow, good aroma ,,,, (well, while writing this blog did not eat, imagine,) you can directly Wolf down the have? What? You want her to chew it up and feed it to you? !!!!!!!!! Get out of here…

I. About Spring Boot

Before we start to understand Spring Boot, we need to know about Spring first, because the birth of Spring Boot is closely related to Spring, Spring Boot is a product of Spring development to a certain extent, but it is not the replacement of Spring. Spring Boot is designed to make it easier for programmers to use Spring. Some people may be confused by this, but what is the connection between Spring and Spring Boot?

1. The history of the Spring

Before we get started, let’s take a look at Spring, formerly known as Interface21. This framework was originally designed to solve the problem of bulky EJB development and provide a simple and practical solution for J2EE. After the official release of Spring 1.0 in March 2004, Since then, Spring has become a dazzling star in the Java world and irreplaceable. It has also become a real standard in J2EE development. Rod Johnson, the founder of Spring, has become famous and rich after that. Now I am a good angel investor, on the top of my life.

2. The Spring Boot was born

Since Spring has been so good, why Spring Boot?

Because as Spring has become more and more popular, it has grown from a small and sophisticated framework to a comprehensive framework. On the other hand, with the development of new technologies such as NodeJS, Golang, and Ruby, Spring has become more and more cumbersome. Spring users are suffering from a lot of tedious XML configuration and third-party integration configuration, and a solution is urgently needed to address these issues.

At this juncture, Spring Boot came into being. Spring Boot was developed in 2013, and Spring Boot 1.0 was officially released in April 2014. Spring Boot attracted wide attention from the industry at the beginning of its birth, and many individuals and enterprises began to try it successively. With the release of Spring Boot 2.0, Spring Boot is once again in the public eye, and more and more medium and large enterprises are using Spring Boot in formal production environments. It is worth mentioning that Spring has also taken Spring Boot as the primary promotion project and placed it in the first place on the official website.

3. The Spring Boot is introduced

Spring Boot is a new framework from the Pivotal team designed to simplify the initial setup and development of Spring applications. The framework uses a specific way to configure so that developers no longer need to define boilerplate configurations. Spring Boot is a framework that integrates a number of pluggable components (frameworks) with built-in tools (such as Tomcat, Jetty, etc.) for quick setup and development.

The above explanation is for everyone to facilitate understanding, deepen memory… Here is the official introduction:

Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". We take 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.
Copy the code

I can’t help but want to translate:

Spring Boot makes it easy to create stand-alone, production-grade Spring-based applications that you can "run straight". We have insights into the Spring platform and third-party libraries so you can easily get started. Most Spring boot applications require very little Spring configuration.Copy the code

The general meaning is that it is really easy to use, it can let you in the construction of the service without a lot of tedious configuration, after using the experience: “almost helpless”…

4. The Spring characteristics of the Boot

  • Project construction is fast, it can be completed in a few seconds;
  • Let the Test become simple, built-in JUnit, Spring Boot Test and other testing frameworks, convenient testing;
  • Spring Boot makes configuration easy. The core concepts of Spring Boot are: For example, if the model and table name are consistent, CRUD (add, delete, change, check) operations can be performed directly without configuration. Only when the table name and model are inconsistent, configure the name.
  • Embedded container, save the tedious configuration of Tomcat;
  • The Spring Boot Actuator component provides system monitoring of applications and allows you to view detailed information about application configurations.

Second, development environment

Spring Boot 2.0.4

JDK 1.8

IDE: IntelliJ IDEA 2018.2

Note: Spring Boot 2.x requires Java8 or later. Java6 and Java7 are no longer supported.

Development tools

IntelliJ IDEA Vs MyEclipse

The choice of development tools is something every beginner has to go through and choose. If you are a veteran, you can skip this section.

There was a time when Eclipse and MyEclipse dominated Java users, and now, year after year, I feel no change from MyEclipse 6.0 ten years ago to MyEclipse 2017. It’s the same skin, the same layout, Even after following Google’s instructions and optimizing a bunch of configurations, you’ll find that the same card feels like a takeoff.

It reminds me of nokia in its glory days. To this day, it still doesn’t know what it did wrong, but as time passes, when something fails to keep pace with the changing times, it is replaced by something more suitable. I have to say I used to be a big fan of MyEclipse, and it’s often hard to change something once you’ve accepted it, out of habit.

However, to this day, I have to admit that IntelliJ IDEA is much better than MyEclipse in terms of appearance and speed, especially Spring Boot support, so it’s a natural fit, so IntelliJ IDEA is the best choice.

Iv. Description of Spring Boot version number

The SpringBoot version on the official website is listed as follows:

What does the English after the version number mean?

The specific meanings are as follows:

  • SNAPSHOT: indicates the SNAPSHOT version. It is subject to change at any time.
  • M1 (Mn) : M stands for milestone, which is the milestone version;
  • RC1 (RCn) : RC stands for Release Candidates.
  • Release: the official version, or may be the official version without any suffix;

Five,springBoot core functions

Spring Boot can be run directly in the form of jar packages, such as java-jar xxxjar. The advantages are: saving server resources

☆ Embedded Servlet container: Spring Boot has the option of embedding Tomcat, Jetty, so we don’t need to deploy projects as war packages.

☆ Provides starter to simplify Maven configuration: The Spring Boot project provides a number of spring-boot-starter-xxx projects (we can call this dependency to start dependencies). If we import the specified coordinates of these projects, the dependency packages related to this module will be automatically imported: For example, when we use Spring Boot for web development, we need to import the dependency of spring-boot-starter-Web. After importing this dependency, we need to import the dependency of Spring-boot-starter-Web. Spring Boot automatically imports the other dependencies required for Web development, as shown below:

Spring Boot will automatically configure beans for classes in jar packages based on the classes in the classpath. This will greatly reduce the configuration we need to use. Of course, Spring Boot only considers most development scenarios, but not all of them. If we need to automatically configure beans in actual development and Spring Boot does not meet this requirement, we can customize the automatic configuration. ☆ Quasi-production application monitoring: Spring Boot provides monitoring of running projects based on HTTP, SH, and Telnet

☆ No code generation and XML configuration: Spring Boot makes extensive use of new annotation features provided by Spring 4.x to implement no code generation and XML configuration. Spring 4.x advocates a combination of Java configuration and annotation configuration, while Spring Boot implements all of Spring’s configurations without any XML configuration.

How is automated configuration done?

Spring Boot gives us a lot of conditional annotations to do this with

Vi. Supplementary Contents:

What thing! ? Don’t you get it? Want to get to know her better? Ok, I’ll stick something for you (a little messy, you can browse) :

On the morning of March 1, 2018, Spring Boot 2.0, as promised, failed to synchronize to Maven repository, resulting in the withdrawal of v2.0.0.RELEASE on GitHub. After the problem was fixed, Spring Boot 2.0 was officially reissued and Maven’s central repository address was provided. Spring Boot2.0 is now available!

The release was 17 months in development and received more than 6,800 submissions from 215 different users, officials said. Many thanks to everyone who contributed, and to all the early adopters who provided important feedback on these milestone releases.

This release is the first major revision since The release of Spring Boot 1.0 four years ago and the first GA stable release to provide support for Spring Framework 5.0. So where to find SpringBoot?

Good, good question! :

How’s that? It’s a familiar place. Yes, this is the Spring family, with SB (SpringBoot and the future SB) also a member, and you can consider her a good friend (●’◡’●) Blue *\(₃•๑ * *)* or a very regular girlfriend, whatever… Anyway, she makes it very easy for us to deal with Spring.

In addition, springBoot2.x has really changed:

Highlights of the new version to watch:

Java boot2 is based on Java 8 and supports Java 9, which means that it is not impossible to run SpringBoot2 using JDK7 or older JDK versions. .

2. Quartz scheduler support

3. Greatly simplifies automatic security configuration

4. Support embedded Netty

5.Tomcat, Undertow, and Jetty all support HTTP/2

6. New executor architecture with support for Spring MVC, WebFlux and Jersey

7. Responsive Web programming support using Spring WebFlux/ webflux.fn

8. Provides automatic configuration for responsive programming of various components, such as Reactive Spring Data, Reactive Spring Security, etc

9. Automated configuration and initiator POM for responsive Spring Data Cassandra, MongoDB, Couchbase and Redis

10. Introduced support for Kotlin 1.2.x, and provided a runApplication function that lets you run Spring Boot applications using the conventional Kotlin. See the Support for Kotlin section in the Reference documentation for more information

Spring Boot banner now supports GIF for example:

It is worth noting that many configuration properties have been renamed or removed in Spring Boot 2.0, and Spring Boot has released a new spring-boot-properties-migrator module to facilitate the upgrade. As soon as it is added to the project as a dependency, it not only analyzes the application’s environment and prints diagnostics at startup, but also temporarily migrates properties to the new configuration for the project at run time.

This module is required during the application migration to springboot2.0

conclusion

The world of programming is always open to all who love programming. It is a world of freedom, equality and sharing. I always believe that.