This article was adapted from: Lebyte Article

Spring Boot

For more Java related knowledge, you can follow the public account “LeByte” to send: 999

With features such as out-of-the-box, no-hassle configuration, Spring Boot has become a must-learn open-source project for Java developers. So how can developers quickly get started with Spring Boot?

Enter the Spring Boot world

The Java (object-oriented programming language) has evolved over the past 30 years and has produced many excellent frameworks. Spring (a framework created to address the complexity of enterprise application development) used to be one of the most popular Java frameworks. However, with the booming development of Scripting languages such as Node, Ruby, Groovy, and PHP, developing applications using Spring has become cumbersome because it uses a large number of XML configuration files. Integration is difficult and development and deployment inefficient. At this time, there was an urgent need for a new rapid development framework to solve these problems, so Pivotal Software company started the development of Spring Boot in 2013.

Spring Boot is designed to solve the problem of too much configuration work for various versions of Spring, simplify the initial construction process and reduce the difficulty of development, so that developers only need to focus on the implementation of application functions and business logic, and do not spend too much time on configuration.

Using the concept of “default is greater than configuration,” Spring Boot provides a number of integrated solutions that allow programmers to develop applications with zero or minimal configuration. It also supports custom operations for flexibility.

It used to be common for a beginner to spend half a month reading several Spring programming books and mastering the basics of theory, only to get stuck in the initial environment configuration when it came time to actually start developing. It could take days to configure the environment badly.

I once met a developer who spent a month without setting up the initial environment. This is hard to imagine, in the face of such cumbersome, inefficient configuration and development work, even people doubt their ability. This ends up being so painful that many people give up in agony, and the developers who stick it out still face a lot of cumbersome configuration work as they work on new projects. The experience with Spring Boot is completely different and “out of the box.”

1.1 Development process of Spring Boot application

(1) Install JDK (Java Development Kit) Development environment and IDE tools (such as Eclipse and IDEA).

(2) In the development tool, the project management software Maven (or Gradle) to build and manage the project.

To use a JAR (Java ARchive) package, you simply write it directly in the pom.xml (or build. Gradle projects) file in the convention format. Maven automatically downloads and configures the JAR dependencies from the repository, and you can then use the methods it provides directly in the class.

Spring Boot comes with more than 50 built-in starters for quick configuration and use. For example, to use the Email service, simply add the “spring-boot-starter-mail” dependency and call JavaMailSender directly

(3) During the development process, you can run and test directly in the IDE tool, and there is no need to set up the Tomcat server environment, because Spring Boot is already built in.

(4) After the completion of development, use IDE tools to directly compile the program into A JAR package, you can directly run under the Java Runtime Environment (JRE) independently. If you want to deploy a running application in a specific or multiple environment, you can also package it as a WAR (Web archive file that contains all the content of the Web application) package.

As you can see, Spring Boot saves us the tedious configuration work, and developers only need to focus on business logic development.

In a word, Spring Boot is an extension and automation of the Spring framework.

Relationship between Spring, Spring Boot, and Spring Cloud

2.1 the Spring

The Spring framework, created to address the complexities of enterprise application development, provides comprehensive infrastructure support for developing Java applications. It provides dependency injection and “out of the box” modules such as Spring MVC, Spring JDBC, Spring Security, Spring AOP, Spring IoC, Spring ORM, and Spring Test. These modules greatly shorten the development time and improve the efficiency of application development.

Prior to Spring, Java Web development was very complicated; for example, if you needed to insert records into a database, you had to write a lot of code to open, manipulate, and close the database. By using the JDBCTemplate of the Spring JDBC module, only data manipulation is required, and Spring manages opening and closing. And it only takes a few lines of code to configure these data operations.

2.2 Spring Boot

Spring Boot is an extension and automation of the Spring framework. It eliminates the CONFIGURATION of XML (EXtensible Markup Language) files in Spring (if you are used to XML configuration, it can still be used), making development faster, more efficient, and more automated.

2.3 Spring Cloud

Spring Cloud is a distributed service governance framework. It does not provide specific functional operations by itself, but only focuses on communication, fusing and monitoring between services. Therefore, many components are required to support a set of functionality. Spring Cloud is primarily used to develop microservices.

Microservices are units of service that can be independently deployed, horizontally scaled, and independently accessed. Spring Cloud is the “CTO” (Chief Technical Officer) of these microservices, providing solutions to maintain the entire ecosystem.

2.4 The relationship among the three

As can be seen from the introduction of the three above, Spring Boot is actually dependent on Spring, rather than creating a new framework from scratch. It is the automation of Spring. Spring Cloud relies on Spring Boot to build microservice applications.

Spring Boot features

3.1 Easy To Use

Spring Boot supports annotation to easily implement class definition and function development, no code generation and XML configuration, easy for beginners to get started.

3.2 Simple Configuration

Spring Boot automatically configudes beans based on the JARS and classes in the classpath. Java gets its name from Java, a coffee commonly consumed by programmers. This coffee is made from Java beans. So, they named the class after beans. Many library class names in the Java language, mostly coffee-related, such as coffee beans — JavaBeans, network beans — NetBeans, and ObjectBeans — ObjectBeans), automate a lot of configuration. At the same time, it also supports custom configuration.

3.3 Provides simplified Starter configurations

Spring Boot provides a number of starters to simplify dependency configuration. For example, if you want to use Redis, add the Starter dependency “spring-boot-starter-data-redis” to the pum. XML file. Spring Boot will automatically load related dependency packages. Redis operation API (Application Programming Interface) is also provided.

3.4 Simple Deployment

Spring Boot can run independently in an environment with JRE (Java runtime environment). It has built-in Servlet (Server Applet) containers such as Tomcat, Jetty, and Netty. Projects do not need to be packaged in WAR format and can be directly run in JAR packages.

3.5 Natural integration with cloud computing

Spring Cloud, a very popular microservices development framework, is also implemented based on Spring Boot.

3.6 Simple Monitoring

It provides a complete set of monitoring and management of application status function modules, including monitoring application thread information, memory information, application health status and so on.

Thank you for your recognition and support, xiaobian will continue to forward “LeByte” quality articles