Spring Boot is so popular right now, there are so many technical articles and paid tutorials, and for those of you who don’t know what Spring Boot is, what is it? What’s the use? Today I will give you a detailed introduction.

What is SpringBoot?

IO /projects/sp…

Spring Boot makes it very easy to develop stand-alone, production-level Spring-based applications by “just running “;

We provide out-of-the-box setup for the Spring platform and third-party libraries so you can get started. Most Spring Boot applications require very little Spring configuration;

Spring Boot is a new development framework under the Spring family, which is designed to simplify the creation and development process of Spring applications. It provides automatic configuration, starter dependency and other features, so that developers can free from a large number of XML configuration. Spring Boot is committed to being a leader in the burgeoning field of rapid application development.

SpringBoot 2.x series updates to the latest version of the SpringBoot series, allowing you to experience the SpringBoot development framework in one go.

Watch online: www.bilibili.com/video/BV1pK.

Data download: www.bjpowernode.com/javavideo/2…

Features:

  • Create a separate Spring application;
  • Embed directly into Tomcat, Jetty, or Undertow (without deploying a WAR file);
  • Provide self-righteous “starter” dependencies to simplify build configurations;
  • Automatically configure Spring and 3rd Party libraries whenever possible;
  • Provide functionality that can be used in a production environment, such as metrics, health checks, and externalized configuration;
  • No code generation at all, and no XML configuration required;

Github:github.com/spring-proj…

With SpringBoot, you can easily create spring-based production-grade applications and services without too much effort. SpringBoot is based on the SpringFramework to make it easy for both existing and new users to get started quickly. You can use SpringBoot to create standalone Java applications and run them through Java-JAR, or create Web projects and launch them through a WAR deployment. SpringBoot also provides command-line tools to run Spring scripts.

The main objectives of SpringBoot are:

  • A fundamentally faster starter development experience for all Spring development (faster and easier to develop);
  • Out of the box, SpringBoot solves common problems as requirements change, such as quickly integrating other components;
  • Provides a range of non-functional features common to large projects (such as embedded servers, security, performance metrics, health checks, external configuration) with no code generation and no XML configuration required;

To sum up, the Spring family launched the Springboot framework in order to simplify the configuration and development of Spring, making the development based on the Spring framework faster and more convenient, simplifying or reducing the relevant configuration, and improving the development efficiency;

SpringBoot development environment

1. Spring Boot is currently divided into two major version series, 1.x series and 2.X series. The latest official version of Spring Boot is 2.3.1.RELEASE.

Spring Tool Suite (STS) is recommended for eclipse development.

3. If you use IDEA flagship version, SpringBoot plug-in comes with it;

4. Java8 is recommended. Spring Boot1. x series is compatible with Java6.

Maven 3.3+ is recommended for springBoot2.x. If the Maven version is too low, an error will be reported. Maven 3.6.3 is the latest version. maven.apache.org

SpringBoot Java Application

How to modify the startup logo log:

Place the banner. TXT file in SRC /main/resources

Paste the new logo text into the banner. TXT file.

In the Spring Boot framework, create a pure Java program:

A:

1, SpringBoot development of pure Java programs, should use the following starting dependency:

2, directly in the main method, according to the SpringApplication.run() method to get the returned Spring container object, and then get the business bean to call;

Method 2:

1, SpringBoot development of pure Java programs, should use the following starting dependency:

2. The Spring Boot entry class implements the CommandLineRunner interface;

The CommandLineRunner interface is overridden by the run() method, in which the specific processing logic is written;

From for SpringMVC to SpringBoot

We through a case, learn and master the development of SpringBoot;

Create a SpringBoot project

A:

IDEA plugin or Eclipse Spring Tool Suite (STS) plugin. (The URL path has two options)

IO/start. Spring

Aliyun: start.aliyun.com/

Method 2:

Use Maven to create projects directly, and then manually add dependencies. (Without network)

Springboot project structure and Maven dependencies

Also a standard Maven structure, with a front-end template technology static and template folder;

The SpringBoot project uses JSP

To use JSP in Spring Boot, follow these steps:

1. Configure dependencies in the POM.xml file

2. Configure the spring MVC view display to JSP in the application.properties file:

spring.mvc.view.prefix=/

spring.mvc.view.suffix=.jsp
Copy the code

3. Create a WebApp directory under SRC /main and create a new JSP page in that directory

4. Configure the page compilation location in Maven’s POM.xml

SpringBoot integration MyBatis

The steps for Spring Boot to integrate MyBatis are as follows:

1. Configure the related JAR dependencies in POM.xml.

2. Configure the data source in the Springboot core configuration file application.properties:

spring.datasource.username=root spring.datasource.password=123456 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver Spring. The datasource. Url = JDBC: mysql: / / 192.168.172.128:3306 / workdb? serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&useSSL=falseCopy the code

3. Generate Mapper interface and Model class through myBatis reverse engineering;

4. Add @mapper annotation to MyBatis Mapper interface;

Or on the running main class

MapperScan(” com.bjPowerNode. mapper”) annotation package scan;

5. The next step is to write code in accordance with the SSM framework.

Note: Idea when you paste a file from somewhere else, it is not compiled and needs to be compiled manually;

SpringBoot add delete change check

Consistent with the original Ssm project development;

Hot deployment plug-ins for the SpringBoot project

Hot deployment means that when we change the code, the service automatically restarts to load the new content, which greatly improves the efficiency of our development.

Spring Boot hot deployment is achieved by adding a plug-in;

The Maven plugin is spring-boot-devtools. The Maven plugin is configured as follows:

There are some minor problems with the hot deployment plug-in in practice, especially for distributed development, such as dubbo development framework, which has some problems and requires manual restart.

JRebel hot deployment plugin for Idea

Jrebel is a paid plugin that needs to be cracked, and it can be hot deployed. Here are some tips for cracking Jrebel:

1. First generate a GUID, which can be generated using the url: www.guidgen.com/

2. Activate with the GUID generated by the url jrebel.qekang.com/ +;

Such as:

Jrebel.qekang.com/0b2e2ca8-6d…

3. Set the mode as offline in Idea to prevent failure;

File -> Settings -> JRebel -> [Work Offline] button click;