What is Spring boot?
We know that spring has been developing rapidly since 2002 and has become a real standard in Java EE (Java Enterprise Edition) development, but with the development of technology, Java EE is becoming unwieldy with spring. , a large number of XML files exist in the project. Cumbersome configuration, the integration of third-party framework configuration problems, resulting in less development and deployment efficiency.
In October 2012, Mike Youngstrom created a feature request in spring Jira that required support for the container-free WEB application Architecture in the Spring framework. He talked about configuring the Web container service within the main container boot spring container. Here is an excerpt from the JIRA request:
I think spring's WEB application architecture can be greatly simplified if it provides tools and reference architectures that take advantage of spring components and configuration models from top to bottom. main()
embed and unify the configuration of these common web container services within a simple method-guided Spring container.
This requirement prompted the development of the spring Boot project starting in early 2013, and today, the spring boot version has reached 2.0.3 release. Spring Boot is not a solution to replace spring, but rather a tool that works closely with the spring framework to enhance the spring developer experience. It also integrates a large number of commonly used third-party library configurations, and these third-party libraries in spring boot applications can be out-of-the-box (Out-of-the-box) for almost 0 configurations, and most spring boot applications require very little configuration code (Java-based configuration). Developers can focus more on business logic.
Why learn spring boot from Spring official view
We open Spring's official website and can see:
We can see the official positioning of Spring Boot in the diagram:build anything, build anything. Spring boot is designed to start and run as fast as possible, and requires minimal spring pre-configuration. We also look at the official positioning of the following two:
Springcloud:coordinate anything, co-ordinate any matter;
Springcloud Data Flow: Connecteverything, connected to anything.
Take a closer look at Spring's website, which has a taste for the positioning of spring Boot, Springcloud, and Springcloud Data flow, and also shows that spring officially attaches great importance to these three technologies, Is the focus of current and future studies (Springcloud-related talent courses will also be online).
From the advantages of spring boot
What are the advantages of Spring Boot? What are the main problems that we have solved? We have explained:
Good genes.
Spring Boot was born with spring 4.0, and literally understood that boot was meant to be guided, so spring boot was designed to help developers quickly build the spring framework. Spring Boot inherits the excellent genes from the original spring framework, making spring easier and faster to use.
Simplify coding
For example, for example, if we were to create a Web project, the Friends of spring would know that when you use spring, you need to add multiple dependencies to the Pom file, and spring boot will help develop a quick launch of a Web container, in spring boot , we only need to add the following starter-web dependency in the Pom file.
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId></dependency>
When we click into this dependency, we can see that the spring Boot Starter-web already contains a number of dependencies, including dependencies that need to be imported in the spring project, and let's look at some of them as follows:
<!--..... Omit other dependencies--<Dependency><Groupid>org.springframework</Groupid><Artifactid>spring-web</Artifactid><Version>5.0.7.release</Version><Scope>compile</scope></dependency><dependency> < groupid>org.springframework</ groupid> <artifactid>www.mhylpt.com/spring-webmvc</artifactid> < version>5.0.7.release<www.taohuayuan178.com/version> <scope>compile </scope></ DEPENDENCY>
As can be seen, Spring Boot greatly simplifies our coding, we do not have to import dependencies, directly a dependency can be.
Simplified configuration
Spring makes Java EE a lightweight framework, but due to its cumbersome configuration, it was once thought to be "config hell". A variety of XML, annotation configuration will be dazzling, and configuration more words, if the error is difficult to find out why. Spring boot is more about configuring spring with Java config. As an example:
I create a new class, but I don't have to @Service
annotate it, that is, it's an ordinary class, so how do we make it a Bean for Spring to manage? Only @Configuration
@Bean
Two annotations are required, as follows:
public class TestService { public String sayHello () { return "Hello Spring Boot!";
import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class JavaConfig { @Bean public TestService www.yongshiyule178.com getTestService() { return new TestService(www.feifanyule.cn);
@Configuration
Indicates that the class is a configuration class that @Bean
indicates that the method returns a Bean. This will be used TestService
as a bean to manage the Spring, and elsewhere, if we need to use the bean, and the same as the original, directly using @Resource
annotations injected into the use, very convenient.
@Resourceprivate TestService testService;
In addition, in terms of deployment configuration, Spring has multiple XML and properties configurations, requiring only one application.yml in spring Boot.
Simplify deployment
When using spring, the project deployment requires that we deploy Tomcat on the server, then throw the project into a war package into Tomcat, and after using spring boot, we don't need to deploy Tomcat on the server because the spring boot embedded Tom Cat, we just need to make the project into a jar package, using java -jar xxx.jar
a one-click Startup Project.
In addition, the basic requirements for the operating environment are reduced, and the JDK is available in the environment variables.
Simplified monitoring
We can introduce spring-boot-start-actuator dependency and use the REST method to obtain the running time performance parameters of the process, so as to achieve the purpose of monitoring, it is more convenient. But spring Boot is just a micro-framework, does not provide the corresponding service discovery and registration of the matching features, no peripheral monitoring integration solution, no perimeter security management scheme, so in the microservices architecture, also need Spring Cloud to work together with.
Judging from the trend of future development
MicroServices are a trend in the future, and the project will slowly shift from a traditional architecture to a microservices architecture, because microservices can enable different teams to focus on a smaller range of job responsibilities, use independent technologies, and deploy more securely and more frequently. It inherits the fine features of spring, same strain with spring, and supports the implementation of various rest APIs. Spring boot is also the official highly recommended technology, it can be seen that spring boot is a major trend in the future development.
What is Spring boot?