Spring MVC 4 Series Tutorial (iii) new features of--spring4.x

Source: Internet
Author: User

new features of 1.spring4.0

from2004yearsSpringof the1.0after the release, a number of important versions are released later:Spring2.0provides aXMLcommand Space andAspectJof support;Spring2.5The note driver is proposed (Annotation-driven) configuration;Spring3.0a cross-frame code library is introducedJava 5+, based onJavaof theConfiguration model and so on.

Spring 4.0 is the most recently released major release and is fully supported for JAVA8. Of course, you can continue to use the lower version of Java, but the minimum is java SE6. the Spring 4.0 also removes many deprecated classes and methods.

Upgrade please refer to the Spring4.0 method:

Https://github.com/spring-projects/spring-framework/wiki

1.1 An improved introductory experience

The new sping.io website provides a series of introductory guides for beginners in Spring. The site also offers a lot of spirng -based projects for developers to learn.

If you use it regularly Maven, you should also be interested in the Spring 's companion BOM (Bill of materials) .

1.2 deleted packages and methods

Spring4.0 has removed many packages, classes, and methods, so before upgrading to 4.0 , make sure that outdated code is repaired.

to see all the changes in 4.0, see:

http://docs.spring.io/spring-framework/docs/3.2.4.RELEASE_to_4.0.0.RELEASE/.

1.3 JAVA8

Spring4.0 can support Many features of Java 8. You can use lambda with Spring 's callback interface

Expressions and Method. java.time support was provided, and many annotations were modified through @Repeatable.

Spring4.0 maintains compatibility with lower Java versions, but it can only be a JDK 6 released in 1 months of the year Update 18. Then, for new SPRING4-based projects, it is recommended to use java7 or java8.

1.4 Java6/java7

java EE 6, JPA 2.0 , servlet 3.0 is considered a spring 4 baseline google apps, other older application services that are compatible, may spring 4 integration into servlet 2.5 environment. However, it is advisable to use the servlet 3.0 above.

Spring4 supports JAVA EE7 level related specifications, especially JMS 2.0, JTA 1.2, JPA 2.1, Bean Validation 1.1, and JSR-236 parallel tools.

1.5Groovy Bean Definition DSL

The groovy DSL allows you to define an external bean configuration file within the Spring4. This is similar to the XML definition Bean method, but the syntax is more minimalist. Using Groovy also makes it easy to embed Bean Definitions in the bootstrap code . For example:

For more information, please refer to:

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/factory/groovy/ Groovybeandefinitionreader.html

1.6Core Container Improvement

Spring4 's core container has many improvements:

when The bean is injected,Spring can use the generic as a modifier. For example, if you want to use Spring 's Repository, you can do this by injecting: @Autowired repository<customer> Customerrepository.

If you have used spring 's meta annotation support, you can now develop custom annotations from meta annotations to implement custom attributes.

As with the @bean definition, @Lazy annotations can also be used at the injection point (injection points) .

development can use @Description annotations using Java -based configuration .

The generalized model of conditional filter Bean is added by @conditional annotations .

1.7General Web Improvements

The Spring4.0 framework currently supports only Servlet 3.0 environments, and if you use the Spring MVC Test framework, you must ensure that the classpath in a Servlet 3.0 compatible JAR package.

You do not have to use @responsebody after each @requestmapping method, and you can use the new @RestController to implement it.

Provides comprehensive time zone support.

1.8Testing Improvements

Spring Framework 4.0 adds a lot of new features to unit testing and integration testing:

Almost all the annotations in the Spring-test module (e.g. @contextconfiguration,

@WebAppConfiguration, @ContextHierarchy, @ActiveProfiles, etc.) can be used as meta-annotations to create custom combinations of annotations, reducing configuration duplication through a test suite;

by implementing Activeprofilesresolver, and through the registration of the resolver property of the @ActiveProfiles, can realize the automatic parsing dynamic class (Active bean definition);

Introducing the Socketutils class in the Spring-core module, you can scan local TCP and UDP ports. Although this feature is not intended for testing, It is proven useful when sockets is required in integration testing.

new features of 2.spring4.1

1.JAVA Message Service (JMS) Improvements

Spring 4.1 introduces @jmslistener to register the JMS listener side (JMS listener endpoints), while introducing XML space Jms:annotation-driven to support this style. The listener can also be registered using Jmslistenerconfigurer.

The spring-messaging introduced in Spring 4.0 also benefits in 4.1: benefiting from standard message annotations @Payload, @Header, @Headers, and @SendTo, You can implement a digital signature on the listener side of the message.

There are many other improvements in the Spring4.1:

Support asynchronous request- answer operation with Jmstemplate;

The listener priority can be specified through the <jms:listener/> property;

by implementing Backoff can configure recovery options for message listening mode.

Spring MVC 4 Series Tutorial (iii) new features of--spring4.x

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.