Do you know the change of Spring from Spring3 to Spring5?
Foreword:
**With the development of Internet technology, Spring is also constantly evolving, from the earliest lightweight Supporting J2EE to the present support for high-concurrency, multi-threaded asynchronous programs, spring is also constantly updating itself to be at the forefront of technology, let’s start with Spring3 to see the development and changes of spring
Spring3
Do you know Spring from Spring3 to Spring5 The changes?
Spring4
You know Did Spring change from Spring 3 to Spring 5?
Spring5
You Know the changes of Spring from Spring3 to Spring5?
Architecture changes between Spring Framework 4.x and Spring Framework 3.2.x
1. As can be seen from the figure, the overall hierarchical structure has not changed much, but Spring 4.0.3 has changed. The struts module (spring-struts package). Added WebSocket module (spring-websocket package), added support for WebSocket, SockJS and STOMP, it is compatible with JSR-356 Java WebSocket API. In addition, a callback scheme based on SockJS (simulation of WebSocket) is also provided to adapt to browsers that do not support the WebSocket protocol.
2. At the same time, a messaging module (spring-messaging) is added, which provides support for STOMP, and an annotation programming model for routing and processing STOMP messages from WebSocket clients. The spring-messaging module also contains the core abstract classes in the Spring Integration project, such as Message, MessageChannel, and MessageHandler.
3. If you look at the source code, you can also find that there is a new package that enhances the beans module, which is spring-beans-groovy. Applications can be written in Groovy partially or completely. With Spring 4.0, it is possible to use Groovy DSL to define external Bean configuration, which is similar to XML Bean declaration, but the syntax is more concise. Using Groovy can also embed the Bean statement directly in the startup code.
4. Support for JDK: Java 8 support. Of course, Java6 and Java7 are also supported, but it is best to upgrade JDK to Java7 when using Spring framework 3.X or 4.X, because some versions require at least Java7. When using Spring 4.x, the Java EE version must be at least 6 or above, and the support of JPA 2.0 and Servlet 3.0 is required, so the server and web container need to be upgraded accordingly. A more forward-looking note is that Spring 4.0 supports J2EE 7 applicable-level specifications, such as JMS 2.0, JTA 1.2, JPA 2.1, Bean Validation 1.1 and JSR-236 Concurrency Toolkit. You need to pay attention to the version when choosing these jar packages. .
5. Core container enhancement:
Support generic injection of Bean, such as: @Autowired Repository customerRepository
Use meta-annotation to develop and expose the self of specified internal attributes Define annotations.
Order the beans injected into the collection or array through the @Ordered annotation or the Ordered interface.
@Lazy annotation can be used on injection points or @Bean definitions.
Introduce @Description annotations for developers.
Introduce @Conditional annotation for conditional Bean filtering.
CGLIB-based proxy classes do not need to provide a default constructor, because the Spring framework integrates CGLIB internally.
The framework supports time zone management, such as LocalContext
5.Web promotion
Add a new @RestController annotation, so that you don’t need to include it in every @RequestMapping method Add @ResponseBody annotation.
Add AsyncRestTemplate to allow non-blocking asynchronous support when developing REST clients.
Provide comprehensive time zone support for Spring MVC application development.
Spring5
Upgrade to Java SE 8 and Java EE 7
Until now, Spring Framework still supports some deprecated Java versions, but Spring 5 has changed from Liberated from the old burden. In order to take full advantage of Java 8 features, its code base has been improved, and the framework requires Java 8 as the minimum JDK version.
At the API level, Spring 5 is compatible with Java EE 8 technology and meets the requirements for Servlet 4.0, Bean Validation 2.0 and the new JSON Binding API. The minimum requirement for the Java EE API is V7, which introduces minor versions for Servlet, JPA, and Bean Validation API.
Reactive programming model
The most exciting new feature of Spring 5 is its reactive programming model. The Spring 5 Framework is built on a reactive foundation and is completely asynchronous and non-blocking. With a small number of threads, the new event loop execution model can be scaled vertically.
The new spring-webflux module, a reactive-based spring-webmvc, is completely asynchronous and non-blocking, and aims to use the enent-loop execution model and the traditional thread pool model.