Dowemo

New features and enhancements to spring 4.0
Spring is initially released in 2004 years later, with a few significant modifications, spring 2.0 provides xml namespaces and aspectj, spring 2.5 includes configuration.

4. 0 ve ion is the last significan not modification, and a new feature for the fi t time full support for java 8. You can still continue to use older versions of java, but the minimum requirements are promoted to java se 6. We also take advantage of this significant modification to remove many outdated classes and methods.

Upgrade to spring 4.0 guide manual see spring framework gighub wiki.

3. 1 improved getting started experience.

The new spring. Io web site provides a complete introduction to you to learn spring. More guides refer to the 1. Spring getting started for this document. The new web site also provides in-depth understanding of many projects published under spring.

If you're a maven user, you might be interested in the material listing pom file that's now published in each spring version.

3. 2 removes the obsolete packages and methods.

4. 0 versions remove all obsolete packages and many obsolete classes and methods. If you're upgrading from previous releases, you need to ensure that all calls to obsolete apis are fixed.

Full change please refer to the api differences report.

Note that optional third-party dependencies have been upgraded to the version of 2010/2011 ( that's, spring 4 only supports releases after 2010 years ), especially for hibernate 3.6 +, ehcache. For an exception, spring 4 requires hibernate validator 4.3 + and jackson2. 0 + ( spring 3.2 keeps support for jackson1, 8/1, 9, but now obsolete ).

3. 3 java 8 ( and 6 and 7 ).

Spring 4.0 provides support for several new features of java 8, allowing use of lambda expressions, using method references in spring callback interfaces. A good support for java. Time ( JSR-310 ) is to transform several existing annotatio & into @ repeatable, and you can use the parameter name of java 8 to build the code that enables debugging information ( based on the compiler flags of parameters ). ( compiler flags, translators note: Parameter name discovery is the name of the parameter through reflection, not the type.

Spring has retained compatibility with older versions of java and jdk, specifically for java se 6 and higher versions ( lowest jdk6. 18, released in 2010 ). Nevertheless, we recommend that new projects based on spring 4 use java 7 or 8.

3. 4 java ee 6 and 7.

Java ee 6 + and its associated jpa 2.0 and servlet 3.0 are considered the baseline of spring 4. For compatibility with google app engine and old application server, you might want to deploy spring 4 in the servlet 2.5 environment. However, servlet 3.0 + is highly recommended, and it's also a prerequisite for spring testing, as well as a prerequisite for simulation package testing development environment settings.

If you're a websphere 7 user, be sure to install jpa 2.0 packages, if you're weblogic 10.3.4 or later, install the jpa 2.0 patch so that spring 4 can compatibility.
More, spring 4.0 now supports specifications applicable to java ee 7, especially jms 2.0, jta 1.2, jpa 2.1, bean validation fso, and jsr 236 concurrency utilities. Like normal, this support is only intended for a person, such as in tomcat or standalone environments only. However, when spring applications are deployed on a server that's deployed in java ee 7.

Note that hibernate 4.3 is a provider of jpa 2.1, so it's only supported in spring 4.0. Likewise, hibernate validator 5.0 is a provider of bean validation 1.1. As a result, both aren't supported by spring 3.2.

3. 5 groovy bean definition dsl.

From spring 4.0, you can define external beans using groovy dsl. In concept, this is similar to using xml configuration beans, but you can use a simpler syntax. Using groovy also makes it easy to embed bean definitions directly into the boot code. For example:


def reader = new GroovyBeanDefinitionReader(myApplicationContext)


reader.beans {


 dataSource(BasicDataSource) {


 driverClassName = "org.hsqldb.jdbcDriver"


 url = "jdbc:hsqldb:mem:grailsDB"


 username = "sa"


 password = ""


 settings = [mynew:"setting"]


 }


 sessionFactory(SessionFactory) {


 dataSource = dataSource


 }


 myService(MyService) {


 nestedBean = { AnotherBean bean ->


 dataSource = dataSource


 }


 }


}






Learn more about groovybeandefinitionreader 's java docs.

Improvement of 3. 6 core container.

The core container has several improvements:

  • When spring injected beans, generics are treated as a qualifier. For example, you can inject a specific implementation when using spring 's repository.
    @ autowired repository CustomerRepository.
  • Using spring 's meta annotations, you can develop custom annotations that expose specific attributes.
  • A bean can be sorted out when it's assembled into a list or array. Supported by @ order and ordered interface.
  • @ lazy annotations can be used for injection points or on @ bean definitions. Introduced the @ description annotation for developers to use java configuration.
  • Bean beans can be defined by @ conditional annotations. It's similar to @ profile but allows users to customize the development strategy.
  • proxy classes no longer require default co tructor. Support through the objenesis library, which is into spring and published as part of the spring framework. With this strategy, there's no constructor that will be invoked when the proxy instance is generated.
  • Added support for managing time zones. For example, localecontext.

Improvements to 3. 7 web.

The deployment of servlet 2.5 servers is retained, but spring 4.0 is now focused on deployment of servlet 3.0 + environments. If you use the spring mvc test framework, you need to ensure that a compatible jar package with servlet 3.0 is included on the test classpath.

In addition to the support for the following, in spring web modules, the following improvements are also included:

  • Add a new @ RestController annotation to spring.
    In the @ application, we don't add the responsebody to each @ requestmapping.
  • Added asyncresttemplate class that allows asynchronous support when developing rest clients.
  • Full time zone support is provided when developing spring mvc applications.

3. 8 websocket, sockjs and stomp messaging.

The new spring web socket module is fully supported by the client and server based on web socket. It's compatible with jsr 356, java websocket apis, and also provides a back option ( for example, web socket emulation ) for browsers that don't support sockjs.

The new spring messaging module supports stomp as a child of a web socket used with an annotation program model to be used by the path from and processed. As a result, a @ controller can contain both @ requestmapping and @ MessageMapping methods to handle http requests and messages from the client. New spring messaging modules also contain key abstractions extracted from the previous spring integration project as the basis for applications, such as message, MessageChannel, mesaagehandler, and so on.

For more details, refer to the 25 web socket support section.

Improvements to 3. 9 tests.

In addition to removing code that's obsolete in the spring test module, spring 4.0 introduces several new features for unit tests and integration tests:

Almost all annotations of the spring test module ( for example, @ ContextConfiguration, @ WebAppConfiguration, @ ContextHierarchy, @ activeProfiles, etc. ) can be used as a meta annotation to create custom annotations and reduce duplicate configuration in test suites.
A valid bean definition profile can be parsed programmatically, as long as you simply implement custom activeprofilesresolver and register the @ activeProfiles resolver property.
The spring core module introduces a new socketutils class for scanning locally idle tcp and udp server ports. This feature isn't specific to testing, but it's useful when writing integrated tests that require sockets, for example, to start the smtp server, ftp server, servlet container.
From spring 4.0, org, springframework, mock, web package simulation collection is based on servlet 3.0. In addition, some servlet api emulation ( for example, MockHttpServletRequest, MockServletContext, etc. ) has a few enhancements and can be improved by configuration.

http://blog. Csdn. net/tangtong1/article/details/51326887.




Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs