Spring empire
Spring is a development framework that almost every Java developer is familiar with, whether you are a novice programmer or an experienced driver. In modern enterprise application architecture, Spring technology stack has almost become synonymous with Java language, so why can Spring stand out among many open source frameworks and become the industry’s unanimously recognized technical solution? Let’s start with the original Spring Framework and see how it can sweep the board!
Challenge authority and make a name for yourself
In March 2004, the first release of Spring and founder Rod Johnson’s classic, Expert One-on-one J2EE Development Without EJB, broke the conventional thinking in Java Development at the time. Enterprise applications are moving towards “lightweight” development.
The original Spring Framework 1.0 was not as complex as Spring is today, but it did include two of the most core elements of Spring: Dependency injection (IOC) and aspect oriented programming (AOP) are key features that set Spring apart from other excellent frameworks and establish it as a core feature in enterprise applications. Many developers when entering the Java application is likely to feel the meaning of these two functions is not big, because without them, we still can be good business functions, it is, but with the deepening of the iteration and development business, complex and changeable demand began to slowly erode the architecture of the “perfect” originally, the difficulty of the development and testing increases gradually, This is often when we realize the value of Spring. So, even if in the original version of the Spring also encapsulates many partial YeWuXing function encapsulation, such as email, transaction management, etc., but we need to know to make the enterprise applications without Spring is not real these is directly related to business functions, but had nothing to do with business implementation of the above mentioned two core.
Because in the early version of Spring, many functional packages are not as powerful as today’s Spring, so for a long time, we have adopted Spring for project management to integrate other better functional frameworks to complete the architecture mode of system development. For example, the once-popular Spring + Struts + Hibernate architecture can bring back memories of a generation.
Elegant and flexible, absorb countless powder
After Spring’s release and acceptance in the industry, the Spring open source community has become very active. In addition to the community’s own enhancements, other functional frameworks have also adapted and supported Spring. The subsequent Spring 2.x and 3.x releases supported the elegant configuration of annotations and then the more flexible configuration of Java classes, allowing Spring to become more diverse in the configuration of managed beans.
However, with the in-depth application of Spring, tedious configuration problems began to appear. We would find that every time we built a project, we always copied and pasted some template configuration and code. Sometimes we just wanted to achieve a few simple functions, but the configuration content was far more than the writing of business logic code. At the same time, in the framework integration process, there is a potential conflict risk for some co-dependent Jar packages, which makes some complex integration tasks become difficult. As a result, Spring’s “lightness” is not so light compared to other dynamic languages.
Master of wheels, uncertain future
In addition to Java 8 support and dependency injection enhancements in Spring 4.x, for a long time the Spring community was less innovative with its core framework, and more of the community’s energy began to be directed towards its once-close friends. As a result, we found a variety of functional sibling projects in the Spring community, such as Spring Data, which simplifies Data access, Spring Batch, which provides Batch processing capabilities, and Spring Security, which protects application Security.
Although these frames from individuals has certain advantages and advanced concept, but for many existing system, it is difficult to make changes in the functional framework, for these are difficult to get the wheels of the new project application, besides some will try to do some system from scratch, given the learning cost and risk consideration on pit, Few small and medium-sized teams are willing to try these new projects. As a result, some older functional frameworks are hard to replace with these wheels unless there are serious performance or security issues.
During this period, although the Spring community launched so many wheel projects, but really not many in the country widely used, many development teams still only use the most core IOC and AOP, and according to their own team technology stack to integrate more suitable scaffolding for system development.
God soldier born, create brilliant
On April 1, 2014, Spring Boot released its first official release. This project is designed to make it easier for developers to create Spring-based applications and services, enabling existing and new Spring developers to get their Spring functionality as quickly as possible. Today, nearly four years after the 2.x release, Spring Boot is a popular open source project with over 21,000 Commits, 15,000 Commits, and over 400 contributors.
Why is Spring Boot suddenly so popular and respected? The main points are as follows:
- Simplified dependency management: Spring Boot provides a series of Starter POMs, which divide and package various functional modules, making it easier to introduce and use, effectively avoiding JAR conflicts caused by maintaining a large number of dependencies when building traditional Spring applications.
- Automated configuration: Spring Boot provides automated Java configuration classes for every Starter to replace the tedious and not very variable Bean configuration in our traditional Spring applications in XML; With a series of conditional annotations, we can easily replace these automatically configured beans for extension.
- Embedded containers: In addition to the optimization of code organization, the support for embedded containers in Spring Boot is a big plus. “Deploy as a Jar, not a War”) makes packaged Spring Boot applications very lightweight.
- Production-level monitoring endpoints:
spring-boot-starter-actuator
The launch of Spring Boot can be said to be another important innovation on the basis of Spring, for Spring application engineering becomes more perfect. This module does not help us to achieve any business functions, but it gives us more support in architecture operation and maintenance. Through the HTTP interface exposed by this module, we can easily understand and control the operation of Spring Boot applications.
Spring Boot is built on the basis of Spring, but with the support of these features, we change the posture of using Spring, greatly simplifies the various configuration work of building enterprise applications, especially for many beginners, become easier to get started.
Spring Boot 2.0 is coming. Upgrade or not?
The first official release of Spring Boot 2.0 has finally been released. Why is Spring Boot 2.0 so much anticipated? I think there are several reasons for this:
- Support for the latest Java 9
- Built on Spring 5, Spring’s new features are available in Spring Boot 2.0
- Provides automatic configuration for Reactive programming of various components, such as Reactive Spring Data, Reactive Spring Security, etc
- Support for WebFlux, a non-blocking alternative to Spring MVC, as well as embedded Netty Server
- With the release of Spring Boot 2.0, can Spring Cloud Finchley be far behind?
Not all of the new features in Spring Boot 2.0 will have different concerns for different users. In addition, there are many other exciting new features in Spring Boot 2.0, such as: Support for HTTP/2, a more flexible property binding API (configuration content can be read and used without the @ConfigurationProperties annotation), support for Spring Simplified configuration of Security integration, enhancement of Gradle plug-in, optimization of Actuator module and so on. This article will not cover these new features in detail, but will focus on whether we need to upgrade our Spring Boot 1.x to Spring Boot 2.x, and what we need to consider and be aware of during this process.
Changes to Java version requirements
When choosing whether to upgrade Spring Boot, the first consideration is the Java version. In Spring Boot 2.0, the requirements for the Java version have increased, requiring at least Java 8 to be used. If your Spring Boot application is still running on Java 7, there are also Java upgrade costs to consider.
In addition, whether or not you want to use Java 9 will be an important decision to make in the future, as the Spring Boot 1.x release clearly states that there is no planned support for Java 9; In other words, if you want Spring Boot to run on Java 9, you must upgrade to Spring Boot 2.0.
Tips: Although the current version of Spring Boot 2.0 supports Java 9, there are still some issues. For example, JDK proxy support requires AspectJ 1.9, but that version is still in RC; Apache Cassandra is not supported yet; JSP TLDs are also not supported in embedded Tomcat. Running Spring Boot on Java 9 can be used to solve these problems
Upgrade dependent components
The Starter of Spring Boot integrates many excellent third-party components. The upgrade of these components also needs to be considered. In the upgrade process of these components, whether there are changes in the use and other issues. Among them, the most critical components need our attention:
- Tomcat was upgraded to 8.5
- Flyway upgraded to 5
- Hibernate was upgraded to 5.2
- Thymeleaf upgraded to 3
Tips: Tomcat vulnerabilities revealed a few days ago. After checking Spring Boot 2.0, the selected version is 8.5.28, which is a safe version, so you can rest assured to use it.
Dependency reorganization and configuration relocation
In the Spring Boot 2.0 upgrade process, this is probably the area where you will need to make a lot of changes, so I suggest you keep your eyes on it. Since Spring Boot is not a flat layer structure when building the Starter POMs, there is a reference relationship between some function modules Starter, for example: Spring-boot-starter-thymeleaf includes spring-boot-starter-Web because the Thymeleaf template engine must have been used under Spring MVC before. However, in Spring Boot 2.0, WebFlux is no longer unique to Web application solutions, so spring-boot-starter-thymeleaf dependencies no longer include Spring-boot-starter-Web. Developers need to add spring-boot-starter- Web or spring-boot-starter- webFlux to determine which module to use to implement web applications.
In addition to the dependency reorganization similar to the above, there are a lot of repositioning of configuration attributes in Spring Boot 2.0, which will lead to some original configurations will not take effect, and we need to manually modify the keys of these configurations to complete the upgrade adaptation. For example, some servlet-related server.* attributes are relocated under the server.servlet prefix:
Old property | New property |
---|---|
server.context-parameters.* |
server.servlet.context-parameters.* |
server.context-path |
server.servlet.context-path |
server.jsp.class-name |
server.servlet.jsp.class-name |
server.jsp.init-parameters.* |
server.servlet.jsp.init-parameters.* |
server.jsp.registered |
server.servlet.jsp.registered |
server.servlet-path |
server.servlet.path |
For more information about dependency changes, configuration repositioning, and default configuration changes, you can refer to the official upgrade manual: Spring Boot 2.0 Migration Guide
Unnecessary concern
A friend of mine asked on the Spring4All community: If Spring Boot is upgraded to 2.0, there are so many new features in 2.0, will our business code need to be modified as well? Will it be a big risk? Spring Boot 2.0 adds a lot of powerful new features, but it doesn’t throw out the old functionality. So, even if we didn’t use any new features like WebFlux and upgraded our project to Spring Boot 2.0, it didn’t make any difference to continue to use Spring MVC to develop our project. However, as mentioned above, we may need to make some dependency and configuration adjustments to keep the application running properly.
Summary and Prospect
Thank you all for reading the above my thin view of Spring Boot 2.0, I hope that these contents can have certain reference value for you to choose Spring Boot 2.0. This release doesn’t change our understanding of cumbersome Spring applications as much as Spring Boot 1.0, but it still has a lot of edge. With the release of Spring Boot 2.0, the official release of Spring Cloud Finchley is one step closer, as there will be a lot of exciting content in the same release.
As a loyal supporter of Spring Boot and Spring Cloud, I will definitely try to upgrade the current Spring Boot 2.0 migration if time permits. In the future, I also hope to spare some time to continue to share some problems and harvest. With everyone!
For more learning materials or videos, please follow our wechat official account: