Spring3.0 new features

2010-11-06  来源:本站原创  分类:Java  人气:155 

First, the first module of the organization more in detail, from the sub so much to look out of the jar:
Spring3.0 new features

Spring's build system and the reliance on management and use of the Apache Ivy, seen from the source package, also use the Maven.
Maven is a good thing indeed, benefits no longer say, the future hope to further good use of it.

Second, the new features are as follows:
Spring Expression Language (Spring expression language)
IoC enhancements / Java based bean metadata (Ioc enhanced / Java-bean based on metadata)
General-purpose type conversion system and UI field formatting system (common type field format conversion system and the UI system)
Object to XML mapping functionality (OXM) moved from Spring Web Services project (object to XML mapping projects out from the Spring Web Services)
Comprehensive REST support (a wide range of REST support)
@ MVC additions (@ MVC enhanced)
Declarative model validation (declarative model validation)
Early support for Java EE 6 (in advance of the Java EE6 support)
Embedded database support (embedded database support)

Third, the core API for Java 5 upgrade
1, BeanFactory interface, the bean as a clear instance of return, for example:
T getBean (String name, Class requiredType)
Map getBeansOfType (Class type)
Spring3 support for generics, but also goes a step further. Generics should use personal recommendations, there is any harm!
2, Spring's TaskExecutor interface is now inherited from java.util.concurrent.Executor:
Extended support for sub-standard interfaces AsyncTaskExecutor Futures returns results with the Callables.
Mission planning, individual and prefer to Quartz.
3, the new API and the SPI-based Java5 of stateless ConversionService converter and Converters
Replace the standard JDK PropertyEditors
Typed ApplicationListener, this is a realization, "Observer design pattern" used in the event listener.
Event-based programming model, benefits, should consider using in the project, event-based, state migration, design ideas, help sort out the software process, and reducing the coupling project.

IV, Spring expression language
Spring expression language is a syntactically and unified expression language (Unified EL) similar language, but more important functions.
It can be based on XML configuration files and annotations in the bean configuration based on the use of, and as a basis for cross-platform use Spring portfolio expression language support.

Next, is an expression language how to configure a database for the installation of the property:

<Bean class = "mycompany.RewardsTestDatabase">
<Property name = "databaseName"
value = "# {systemProperties.databaseName}" />
<Property name = "keyGenerator"
value = "# {strategyBean.databaseKeyGenerator}" />
</ Bean>

If you prefer to use annotations to configure your component, then this feature also available:

@ Repository public class RewardsTestDatabase {
@ Value ("# {systemProperties.databaseName}")
public void setDatabaseName (String dbName) {...}

@ Value ("# {strategyBean.databaseKeyGenerator}")
public voidsetKeyGenerator (KeyGenerator kg) {...}

The addition of an expression language, the wheel continues in motion!

Fifth, Java-bean based on metadata
JavaConfig project some of the core features have been integrated into the Spring in the past, this means that as these features are already available:

@ Configuration
@ Bean
@ DependsOn
@ Primary
@ Lazy
@ Import
@ Value

Here is an example of a Java class on how to use the new features provide a basis JavaConfig configuration information:

package org.example.config;

@ Configuration
public class AppConfig {
private @ Value ("# {jdbcProperties.url}") String jdbcUrl;
private @ Value ("# {jdbcProperties.username}") String username;
private @ Value ("# {jdbcProperties.password}") String password;

@ Bean
public FooService fooService () {
return new FooServiceImpl (fooRepository ());

@ Bean
public FooRepository fooRepository () {
return new HibernateFooRepository (sessionFactory ());

@ Bean
public SessionFactory sessionFactory () {
/ / Wire up a session factory
AnnotationSessionFactoryBean asFactoryBean =
new AnnotationSessionFactoryBean ();
asFactoryBean.setDataSource (dataSource ());
/ / Additional config
return asFactoryBean.getObject ();

@ Bean
public DataSource dataSource () {
return new DriverManagerDataSource (jdbcUrl, username, password);

In order for this code came into effect, we need to add the following entry to the smallest component of the scan the application context configuration file:

<Context: component - scan base - package = "org.example.config" />
<Util: properties id = "jdbcProperties" location = "classpath: org / example / config / jdbc.properties" />

Sixth, the definition in the component metadata bean Spring <br /> feeling more and more annotations to provide metadata, the complexity is beyond the convenience of the original itself!

VII, General UI field type conversion system and format the system

Spring3 joined a common type of conversion system, which is currently used as a type conversion SpEL, and may be a Spring container, used to bind the bean property value when the time for type conversion.
In addition, the addition of a UI field to format the system, which provides easier use and more powerful features to replace the UI environment JavaBean's PropertyEditors, for example, in the SpringMVC.
This feature should make a thorough study, the common type conversion system if the results are as stated, then still a lot of benefits.

VIII <br /> data layer object to XML mapping function has been moved from the Spring Web Services project in the core Spring framework. It is located org.springframework.oxm package.
OXM? Of next! Time really is not enough!

IX, Web layer in the Web tier <br /> most exciting new features of the component than the new REST-style web applications, web services and support! Also, added some new web applications can use any new comments.
Server-side support for REST-style, through the expansion of the existing annotation-driven MVC web framework for implementation.
Client support is provided RestTemplate class.
Either the server or the client-side REST function, are using HttpConverter to simplify the process of HTTP request and response objects to the presentation layer of the conversion process.
MarshallingHttpMessageConverter using the above-mentioned "object to XML mapping mechanism."

Ten, @ MVC enhance <br /> added @ RequestHeaders such as @ CookieValue and other such comments.

XI, declarative model validation <br /> support JSR 303, use the Hibernate Validator for implementation.

Second, to provide support in advance of the Java EE6 <br /> provides the use of @ Async annotation support for asynchronous method invocation (or EJB 3.1 in the @ Asynchronous) Also, add to the JSR 303, JSF 2.0, JPA 2.0 support, etc. .

XIII <br /> embedded database support for embedded Java database engine provides a broad and convenient support, such as HSQL, H2, and the Derby and so on. Silverlight game development resources and image processing algorithm 2
It does not represent a trend? Development to a growing database of small, even smaller to the embedded, and I think that in the desktop application is still very market.

  • Spring3.0 new features (c) 2010-11-21

    3, three common configurations: XML, Annotation, JavaConfig (spring3.0 new) JavaConfig configuration: @Configuration public class AppConfig { @Bean public UserDAO userDAO() { return new UserDAOImpl(); } //xml //<bean id = "userDAO" } Here are

  • Spring3.0 new features (d) 2010-11-21

    4, SpELTest_Simple (spring express language spring3.0 new) First of all talk about dynamic languages: Is simply the language contains the language, such as: JavaScript inside eval ("alert ('hello');");, this is a typical dynamic language. Simila

  • Spring3.0 new features 2010-11-06

    First, the first module of the organization more in detail, from the sub so much to look out of the jar: Spring's build system and the reliance on management and use of the Apache Ivy, seen from the source package, also use the Maven. Maven is a good

  • Spring3.0 new features (a) 2010-11-21

    1, Jnit4 test first test: @ContextConfiguration("classpath:beans.xml") public class UserDAOTest extends AbstractJUnit4SpringContextTests{ @Resource(name="userDAO") private UserDAO userDAO; @Test public void testSave() { this.userDAO.sa

  • Spring3.0 new features (b) 2010-11-21

    2, context.getBean can use generics, do not cast a @Test public void testSave() { ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml"); UserDAO userDAO = context.getBean("userDAO", UserDAO.class); //UserDAO user

  • spring3.0 mvc learning 2010-03-29

    An environment eclipse spring3.0 tomcat6.0.13 jdk1.6 The jar used packets: spring-related: org.springframework.aop-3.0.1.RELEASE-A.jar, org.springframework.asm-3.0.1.RELEASE-A.jar, org.springframework.beans-3.0. 1.RELEASE-A.jar, org.springframework.c

  • strust2.1 + spring3.0 + ibatis3.0 + annotation 2010-03-01

    Recent development framework choice strust2.1 + spring3.0 + ibatis3.0 To make use of annotation, less use of xml, ibatis, except 1.strust2.1 The plugin is mainly used to the Convention Pluin, because he is the key to achieving Restful and annotation.

  • spring3.0 junit test 2009-02-05

    spring-3.0 modified the test package of classes, the previous org.springframework.test.AbstractDependencyInjectionSpringContextTests And other related classes are not recommended, and Recommended org.springframework.test.context.junit4 (or junit38) p

  • SSH Integration Series 2 - The Struts2.1.8.1 integrating Spring3.0.1 2009-02-14

    As Spring3.0 version and previous version is a major division point. So, there are a lot of changes, where the mere enunciation of an integrated approach, study its new use. 1. The introduction of spring of the jar package 2. Create a Spring configur

  • J2SE 5.0 New Features 2010-03-29

    J2SE 5.0 (Tiger) release of Java language development is an important milestone in the history is so far in the Java programming made the greatest progress. J2SE 5.0 offers many exciting features. These features include generics (generics) support, e

  • spring3.0 aspectj configuration and use of 2010-04-06

    Understand something today, early adopters of the cost to be spent, would like to try this spring 3.0 of the AOP, with aspecj to do configuration, there are too many problems along the way, really troublesome, and good in the final is successful, the

  • Servlet 3.0 new features Xiangjie 2010-05-02

    Description: Servlet is a Java EE specification are an important integral part of Java developers must have the basic skills, Servlet 3.0 is the latest version of the Servlet specification. This paper introduces the Servlet 3.0 introduced a number of

  • Spring3.0 Source Learning --- IOC (1) 2010-05-11

    SVN recently downloaded a Spring3.0 source learning. First introduce the individual to the current understanding of IOC for the Spring in it. Welcome to discuss, Oh, do not Paizhuan. Spring into a realization of the IOC. Resources (Resource) Location

  • JSF2.0 + spring3.0 integrated sample (tomcat6) 2010-06-26

    Introduction: JSF2 is javaEE6 focus "promoting" the presentation layer framework, which has been compared to JSF1.2.x a qualitative change, specific to stop drilling. Spring3 of course, quite strong. Community, like the JSF colleagues who may wa

  • SSH integration of series 2 - the integration of Spring3.0.3 in Struts2.1.8.1 2010-07-08

    Since: http://scorpiomiracle.javaeye.com/blog/615635 As Spring3.0 version and the previous version is a major division point. So many changes, there is only elaborated an integrated approach, not of its new use. 1. The introduction of spring in the j

  • spring3.0 + ibatis + jquery + annotations establish dao.service class 2010-07-19

    spring3.0 Notes demos

  • Derived from the OpenSessionInViewFilter spring3.0 Services configuration error problems and solutions 2010-08-15

    Development environment IDE: eclipse3.4 FrameWork: spring3.0 + spring mvc 3.0 + hibernate 3.2 Server: Tomcat 6.0 Reasons for using OpenSessionInViewFilter Quote Hibernate allows related objects, attributes lazy, lazy, but must ensure that the operati

  • Struts2.2.1 + Spring3.0.5 + Hibernate3.6.0 + Freemarker2.3.16 + MySql5 configuration Memorandum 2010-10-30

    From now on, there is a bold idea, the use of Struts2.2.1, Spring3.0.5, Hibernate3.6.0, Freemarker2.3.16, MySql5 develop a single-user blog site. The following is a summary of bit by bit, long after the update, until the development is completed so f

  • javaEE5.0 new features 2010-11-08

    javaEE5.0 new features

  • Spring3.0 maven pom configuration 2010-11-16

    Spring3.0 posted only the relevant jar package: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.