Spring Boot simplifies the initial construction and development process of Spring applications. Developers can use the specific way provided by Spring to configure applications. There is no need to repeat custom boilerplate configuration. In fact, Spring Boot is not a new framework, it is configured by default to use many frameworks, just like Maven integrated all Jar packages, Spring Boot integrated all frameworks, simple and efficient! What do we usually do when we need to build a Spring Web project?

1) configure web.xml, load Spring and Spring MVC 2) configure database connection, configure Spring transactions 3) Configure load configuration file reading, enable annotations 4) configure log files

Deploy Tomcat debugging after the configuration is complete

Microservices are very popular now, if my project is just to send an email, if my project is just to produce a credit; I need to do it all over again!

But what about using Spring Boot?

Very simple, I can quickly and easily set up a Web project or build a microservice with very little configuration!

1. Create a Spring Boot project

Click jump to Spring Initializr, where you can configure the project’s basic properties, dependency libraries, etc. Then “GENERATE” will download the project locally.

Of these, we chose only three dependent libraries, which are sufficient if you only want to develop a few simple interfaces and access the mysql database.

  • Spring Web

Build web, including RESTful, applications using Spring MVC. Uses Apache Tomcat as the default embedded container.

  • Spring Data JPA

Persist data in SQL stores with Java Persistence API using Spring Data and Hibernate.

  • MySQL Driver

MySQL JDBC and R2DBC driver.

2. Development environment

We have the JDK installed in advance and the development tool uses IntelliJ IDEA. Go to IDEA -> File -> Open

That is, the Spring Boot project we just created opens.

2.1 the pom. The XML file

Pom.xml is the equivalent of the Podfiles in Cocoa Pods. It describes the tripartite libraries that the project depends on, and when opened it already has the configured content. If IDEA does not automatically download these libraries, an error will be reported during compilation. In this case, you need to manually synchronize these libraries. If you have mysql in your dependencies, you need to install mysql first, otherwise you will also get compiler errors.

2.2 application. The properties file

This file, which is empty by default, contains information about the port on which the Web service will run (the port on which Tomcat listens, Spring Boot project comes with Tomcat), mysql configuration of Web services (mysql driver, mysql data source URL, mysql user name and password, etc.), JPA configuration, HTTP encoding, Tomcat encoding, etc.

The specific encoding format may correspond to the data encoding format in mysql; otherwise, garbled characters may appear in some links.

2.3 Debug, package and run
  • debugging

You have to click the 🐞 button in the upper right corner of the runtime to break the point in the code and see the debug log.

  • packaging

After debugging, double-click the package to automatically generate a Jar package.

This JAR package contains all the dependent libraries, Tomcat and the web interface implemented in the project. That is to say, as long as the JAR can be run and the response port of the machine is available, the Web service will pass.

  • run

Switch to the directory where the JAR resides on the terminal and run the Java -jar *. Jar command.

So far this project is empty, how to use this project to complete a simple interface, see later update…