Why is it that Java programmers have to master Spring Boot?

Source: Internet
Author: User
Tags spring boot actuator

Spring Boot 2.0 's launch has also sparked a flurry of learning spring boot heat, just a huge increase in the number of visits from my personal blog can be felt by everyone's enthusiasm for learning spring boot, and I'm thinking about it when so many people are keen to learn spring boot. : What is the background of Spring Boot? What kind of consideration is spring Enterprise creating spring Boot? What changes do traditional companies bring to us using Spring Boot?

With these questions, let's take a look at what Spring Boot is all about.

Spring history

Speaking of spring Boot we had to get to know spring, not only because spring boot came from the Spirng family, but also the birth of spring boot and the development of the sping framework.

Time back to the 2002, when Java EE and EJB were in the big line, many well-known companies are using this technology program for project development. At this time, an American lad thinks that EJB is too bloated, not all projects need to use the large framework of EJB, there should be a better solution to this problem.

In order to prove his idea was correct, in October 2002 even wrote a book "Expert One-on-one", introduced the situation of Java Enterprise application development at that time, and pointed out the Java EE and EJB components in the framework of some of the major shortcomings. In this book, he proposes a simpler solution based on common Java classes and dependency injection.

In the book, he shows how to build a high-quality, scalable online seat reservation system without using EJBS. In order to build the application, he wrote more than 30,000 lines of infrastructure code, the root package in the project named Com.interface21, so people initially called the Open source framework as INTERFACE21, the predecessor of Spring.

Who he is, he is the famous Rod Johnson (), Rod Johnson not only received a computer degree at the University of Sydney, but also received a music degree, more surprisingly, before returning to the field of software development, he also received a doctorate in music. Now that Rod Johnson has left Spring, he has become an angel investor and a director of several companies, and has already embarked on the pinnacle of life.

After this book was released, one-to-two design and development of the Java EE was red. Most of the infrastructure code provided by this book for FREE is highly reusable. 2003 Rod Johnson and his companion developed a brand-new framework based on this framework named spring, which, according to Rod Johnson, introduced spring as a new beginning for traditional java. Then Spring develops into the fast lane.

    • Released in March 2004, version 1.0.
    • Released in October 2006, version 2.0.
    • It was renamed SpringSource in November 2007 and Spring 2.5 was released.
    • Spring 3.0 was released in December 2009.
    • In December 2013, Pivotal announced the release of Spring Framework 4.0.
    • Spring 5.0 was released in September 2017.
The birth of Spring Boot

With the growing number of individuals and businesses that are developing with spring, spring is slowly turning from a single, compact Framework into a chatty open-source software, and the boundaries of spring continue to expand, and spring can do almost anything, with the mainstream open source software on the market, Middleware is supported by spring counterparts, and people are experiencing problems after enjoying the convenience of spring.

Spring every integration of an open source software, you need to add some basic configuration, slowly as people develop projects more and more large, often need to integrate a lot of open source software, so the late use of SPIRNG development large projects need to introduce a lot of configuration files, too many configurations are very difficult to understand, and easy to configure error, Later, people even called Spring to configure Hell.

Spring seems to be aware of these problems, the need for such a set of software to solve these problems, the concept of micro-service is slowly emerging, rapid development of small independent applications become more urgent, spring is at such a crossroads, the beginning of 2013 spring Boot Project Development, April 2014, Spring Boot 1.0.0 released.

Spring Boot was born with the continued attention of the open source community, with some individuals and businesses trying to use Spring boot and quickly like the open source software. It was not until 2016 that spring boot was being used in the country, and many of the spring boot developers wrote a lot of articles about spring boot on the web, while some companies made small-scale use within the enterprise and shared their experience with them. From 2016 to 2018, more and more companies and individual developers using spring boot, as we can see from the Spring boot keyword's Baidu index.

For the 2014 to 2018 Spring boot Baidu Index, it can be seen that the launch of Spring Boot 2.0 triggered a search peak.

Of course spring boot is not intended to replace spring, spring boot is based on spring and is designed to make it easier for people to use spring. Seeing the spring boot market reaction, spring also attaches great importance to the follow-up development of spring boot, has been the spring boot as the company's top projects to promote the first place on the official website, so the continued development of spring boot is also optimistic 。

What is Spring Boot

Spring Boot Introduction

Spring Boot is a new framework provided by the Pivotal team designed to simplify the initial setup and development of new Spring applications. The framework uses a specific approach to configuration, which eliminates the need for developers to define boilerplate configurations. In my words, spring boot is not really a new framework, it is configured with many frameworks by default, as Maven integrates all the jar packages, and spring boot integrates all the frameworks (not knowing if the analogy is appropriate).

Spring Boot simplifies spring-based application development by creating a standalone, product-level Spring application with a small amount of code. Spring Boot provides out-of-the-box settings for the spring platform and third-party libraries so you can get started in a methodical manner. The core idea of spring boot is that the contract is larger than the configuration, and most spring boot applications require little spring configuration. With Spring Boot, you can greatly simplify your development model, and all the common frameworks you want to integrate with the corresponding component support.

Spring Boot Feature

    • Use the Spring Project Guide page to build a project in a few seconds
    • Easy to export various forms of services, such as REST API, WebSocket, Web, streaming, Tasks
    • Very simple security policy integration
    • Support for relational and non-relational databases
    • Supports runtime inline containers, such as Tomcat, Jetty
    • Powerful development package, support hot start
    • Automatic management of dependencies
    • Self-bringing application monitoring
    • Supports a variety of IEDs, such as IntelliJ idea, NetBeans

Spring Boot These features will give us a great advantage in research and development, we can separate to introduce:

Benefits of using Spring Boot

Using the Spring Boot development project will give us a wonderful development experience and can be explained in the following ways

Spring Boot makes development easier

Spring Boot is an all-round upgrade to development efficiency, and we can make a simple comparison:

What we need to do to develop a Web project before we use Spring Boot:

    • 1) Configure Web. XML to load spring and spring MVC
    • 2) Configure the database connection, configure the Spring transaction
    • 3) Configure the load profile to read, open annotations
    • 4) Configuration log file
    • ...
    • N) Deploy Tomcat debugging after configuration is complete

You may also want to consider the compatibility of each version and the various possibilities of jar package conflicts.

So what do we need to develop a Web project after using Spring Boot?

    • 1) Login URL http://start.spring.io/Select the corresponding component to download directly
    • 2) Import project, direct development

The N-step above and the 2 steps below form a huge contrast, which is only in this aspect of the development environment.

Spring Boot makes testing easier

Spring Boot's support for testing is not very strong, and spring boot has built in 7 powerful test frameworks:

    • JUnit: A unit Test framework for a Java language
    • Spring Test & Spring Boot Test: Provides integration testing and tool support for spring boot applications
    • ASSERTJ: Java test framework to support streaming assertions
    • Hamcrest: a matching library
    • Mockito: a Java mock framework
    • Jsonassert: A library of assertions for JSON
    • Jsonpath:json XPath Library

We only need to introduce the dependency package into the project spring-boot-start-test , we can test the database, Mock, the Web and so on.

Spring Boot test contains a variety of test scenarios that we need to use to meet the testing needs of our daily projects.

Spring Boot makes configuration easier

Spring boot makes the configuration simple, and here we need to understand the core idea of Spring boot: the convention is better than the configuration. So what is the contract better than the configuration?

The Convention is better than configuration (Convention over config), also known as convention programming, is a software design paradigm designed to reduce the number of decisions that software developers need to make, and gain simple benefits without sacrificing flexibility.

The essence is that developers only need to specify the parts of the application that are not in conformity with the agreement. For example, if you have a class named user in your model, the corresponding table in the database will be named user by default. Only when you deviate from this convention, for example by naming the table "User_info", should you write a configuration about that name.

Spring Boot makes deployment easier

Speaking of spring boot makes deployment simple, you have to say Spring boot inline container. Inline containers not only make deployment easy, but also provide a lot of convenience in the development debugging phase, compared to the cumbersome use of Tomcat when developing WEB projects, so you'll have a deeper feeling when you're using Spring Boot inline container development. Using Spring Boot to develop WEB projects allows us to focus on writing business code without caring about the environment of the container.

Jenkins is one of the most widely used tools for ongoing construction, and Jenkins is a standalone open source Automation server that can be used to automate a variety of tasks, such as building, testing, and deploying software. Jenkins can be installed through the native System Package Docker and can even be run independently by any machine that installs Java runtime environment.

To be blunt, Jenkins is the software that is specifically responsible for how to turn code into an executable package, deploy it to a target server, and monitor its operational status (logs). Automation, performance, packaging, deployment, publishing, automated validation of release results, interface testing, unit testing, and more all about our packaged test deployment Jenkins can be very friendly to support.

Deploying the Spring Boot project with Jenkins is very simple and you want to continue to understand that you can refer to my article: Deploying Spring Boot with Jenkins requires only a few simple configurations, and when we need to publish a project, we just need to click on the project's corresponding publish button. You can pull, package, and publish the project from the repository to the target server, greatly simplifying the deployment of the later operations.

The development of virtualization technology has brought us more possibilities, we can use containerized technology, the Spring Boot project into a mirror, according to the strategy of the container cluster to achieve elastic expansion, dynamic deployment and so on. So spring boot + Docker + Jenkins will simplify and intelligently deploy the Spring boot project.

Spring Boot makes monitoring easier

It can be said that Spring Boot is a self-monitoring open source software, at the beginning of the design to consider the application of monitoring issues, specifically provides a monitoring component to do this work, this component is
Spring Boot Actuator.

Spring Boot Actuator is an integrated feature of the application monitoring provided by spring boot, which allows you to view details of the application configuration, such as automation configuration information, the Spring beans created, and some environment properties.

Of course Spring Boot actuator can monitor the health of a spring boot application, and in fact today's system requires a lot of services to work with each other, and how to monitor the Spring boot project with a monitoring software will become more urgent.

There are also people in the open source community who are aware of this problem and have made a powerful monitoring software based on spring boot actuator, which is Spring boot admin.

Spring Boot Admin is an open source software for managing and monitoring spring boot applications. Each application is considered a client, and is registered with the admin server via HTTP or using Eureka, and the Spring Boot admin UI section uses AngularJs to present the data to the front end.

Spring Boot Admin is a monitoring tool for UI beautification encapsulation of the actuator interface for Spring-boot. He can: Browse through the list of all monitored spring-boot items, detailed health information, memory information, JVM information, garbage collection information, various configuration information (such as data sources, cache lists, and hit ratios), and can also directly modify the level of logger.

With spring boot Admin, you can monitor not only the spring boot project, but also the spring Cloud project, so we monitor the spring boot cluster after using the Spring boot project as follows:


Simple, intuitive, easy to use is its characteristics, for some special cases can also provide alarm services. So using spring boot actuator solves a single spring boot monitoring problem, and using spring boot Admin solves the whole cluster monitoring problem.

Spring, Spring Boot, and spring Cloud relationships

Spring Ioc and Spring Aop, the two core functions of the first core, spring,spring the continuous development of the two core functions, with a series of great products such as spring transaction, Spirng MVC, and finally the SPR ing Empire, to the late Spring can almost solve all the problems in enterprise development.

Spring boot was developed on the basis of the strong spring empire ecosystem, and the spring boot was invented not to replace spring, but to make it easier for people to use spring. So there is no spring strong features and ecology, there will be no late spring boot fiery, spring boot use convention than the concept of configuration, re-reconstruct the use of spring, so that spring follow-up development more vitality.

Spring Cloud is an ordered collection of frames. It uses spring boot's development convenience to subtly simplify the development of distributed system infrastructures, such as service discovery registration, Configuration center, message bus, load balancer, circuit breakers, data monitoring, and so on, all of which can be started and deployed with spring boot development style.

Spring does not reinvent the wheel, it simply combines the more mature and proven service frameworks currently developed by companies, masking the complexities of configuration and implementation through the Spring Boot style, and ultimately leaving developers with a set of easy-to-understand, Easy-to-deploy and maintainable Distributed system Development Kit.

As we can see from the above, spring cloud is the development framework for a range of features that are provided to address service governance in the MicroServices architecture, and spring Cloud is developed entirely on spring Boot, and Spring Cloud leverages spring Boo The T feature integrates the best components in the open source industry, providing a holistic approach to service governance in the MicroServices architecture.

In conclusion, we can understand that because spring Ioc and spring Aop have two powerful functions to spring, Spring's evolution has spring boot, and spring boot makes it easier for spring to use more life , Spring Cloud is a service governance solution for a microservices architecture developed based on Spring Boot.

Use a less-than-reasonable set of containment relationships to express the relationship between them.

Spring IOC/AOP > Spring > Spring Boot > Spring Cloud

We recommend a website that collects spring boot learning resources: Spring Boot Chinese index

Summarize

I do not know when, some developers in the industry are willing to believe that the use of complex software means the adoption of advanced technology, the use of a large number of configurations, it means that the software has a lot of more powerful features. In the product design when there is a concept is to make the product operation enough fool, assuming that the user is a low IQ group, but can make it easy for him to learn to use their products, this feature as a product design one of the standards.

In fact, our open source software is also a product, cumbersome does not mean that the function is strong, but it may be the design is not reasonable, concise also does not mean that simple, it is possible it just will be a lot of complex features encapsulated, let us in the use of simple enough. Good products So, good open source software should be the case, the advent of Spring Boot is to make programming easier.

In this reference Python's classic design maxim, the maxim comes from Python but not limited to Python.

Beauty is better than ugliness.
Clearly superior to ambiguity.
Simplicity is better than complexity.
Complexity is better than tedious.
Flat is better than twists.
Looser than dense.
The important thing is readability.
Special cases are not enough with special to break the rules.
Although practice can break the truth.
Mistakes are not to be ignored.
Unless otherwise expressly required.
Face ambiguity and refuse to speculate.
There will always be one-preferably one-and the obvious way to discern.
It may not be obvious at the beginning, even though.
Now there is better than nothing.
Though not often better than now.
If the implementation is difficult to interpret, then the idea is a bad idea.
If the implementation can be well explained, then this is a good idea.

The article was excerpted from my share on gitchat.

Why is it that Java programmers have to master Spring Boot?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.