spring2.0 configuration of the new labeling applications

2010-07-09  来源:本站原创  分类:Java  人气:146 

spring2.0 configuration of a new label application 2007-12-28 16:131, <util:constant/>
Replaced before the acquisition by FieldRetrevingFactoryBean bean static constant FactoryBean!

The use of old

<bean>
<property name="isolation">
    <bean
    />
</property>
</bean>

New Usage

<bean>
    <property name="isolation">
        <util:constant static-field="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
    </property>
</bean>

2, <util:property-path/>
Replace the previous path through PropertyPathFactoryBean to specify the property to obtain property value FactoryBean!

The use of old

<bean singleton="false">
<property name="age" value="10"/>
<property name="spouse">
    <bean>
      <property name="age" value="11"/>
    </bean>
</property>
</bean>

<bean/>

The use of new

<bean singleton="false">
<property name="age" value="10"/>
<property name="spouse">
    <bean>
      <property name="age" value="11"/>
    </bean>
</property>
</bean>

<util:property-path path="testBean.age"/>

3, <util:properties/>
Before replacing the preparation by PropertiesFactoryBean to obtain the properties file data FactoryBean!

Old Usage

<bean>
<property name="location" value="classpath:com/foo/jdbc-production.properties"/>
</bean>

New Usage

<util:properties location="classpath:com/foo/jdbc-production.properties"/>

4, <util:list/>
Replaced before the adoption of <list> <value> </ value> </ list> of the built-in preparation to let the bean calls the same list more than possible!

The use of old

<bean>
<property name="sourceList">
      <list>
        <value>[email protected]</value>
        <value>[email protected]</value>
        <value>[email protected]</value>
        <value>[email protected]</value>
      </list>
</property>
</bean>

The use of new

<util:list list-class="java.util.LinkedList">
    <value>[email protected]</value>
    <value>[email protected]</value>
    <value>[email protected]</value>
    <value>[email protected]</value>
</util:list>

5, <util:map/>
Replaced before the application of <map> <entry key=""> <value> </ value> </ entry> </ map> is configured to allow multiple calls to the same map bean possible!

The use of old

<bean>
<property name="sourceMap">
      <map>
        <entry key="pechorin" value="[email protected]"/>
        <entry key="raskolnikov" value="[email protected]"/>
        <entry key="stavrogin" value="[email protected]"/>
        <entry key="porfiry" value="[email protected]"/>
      </list>
</property>
</bean>

The use of new

<util:map map-class="java.util.TreeMap">
    <entry key="pechorin" value="[email protected]"/>
    <entry key="raskolnikov" value="[email protected]"/>
    <entry key="stavrogin" value="[email protected]"/>
    <entry key="porfiry" value="[email protected]"/>
</util:map>

6, <util:set/>
Replaced before the application of <set> <value> </ value> </ set> of configuration,
The same set to have multiple bean calls possible!

The use of old

<bean>
<property name="sourceSet">
      <set>
        <value>[email protected]</value>
        <value>[email protected]</value>
        <value>[email protected]</value>
        <value>[email protected]</value>
      </set>
</property>
</bean>

The use of new

<util:set set-class="java.util.TreeSet">
    <value>[email protected]</value>
    <value>[email protected]</value>
    <value>[email protected]</value>
    <value>[email protected]</value>
</util:set>

7, <jee:jndi-lookup/>
Replaces the previously used preparation for the specified container JndiObjectFactoryBean JNDI resources FactoryBean!

The use of old

<bean>
    <property name="jndiName" value="jdbc/MyDataSource"/>
    <property name="cache" value="true"/>
    <property name="resourceRef" value="true"/>
    <property name="lookupOnStartup" value="false"/>
    <property name="expectedType" value="com.myapp.DefaultFoo"/>
    <property name="proxyInterface" value="com.myapp.Foo"/>
</bean>

New Usage

<jee:jndi-lookup
             jndi-name="jdbc/MyDataSource"
             cache="true"
             resource-ref="true"
             lookup-on-startup="false"
             expected-type="com.myapp.DefaultFoo"
             proxy-interface="com.myapp.Foo"/>

8, <jee:local-slsb/>
Replaces the previously used LocalStatelessSessionProxyFactoryBean to get a stateless session BEAN's FactoryBean!

The use of old

<bean
     >
<property name="jndiName" value="ejb/MyRemoteBean"/>
<property name="businessInterface" value="com.foo.service.RentalService"/>
<property name="cacheHome" value="true"/>
<property name="lookupHomeOnStartup" value="true"/>
<property name="resourceRef" value="true"/>
<property name="homeInterface" value="com.foo.service.RentalService"/>
<property name="refreshHomeOnConnectFailure" value="true"/>
</bean>

The use of new

<jee:remote-slsb
    jndi-name="ejb/MyRemoteBean"
    business-interface="com.foo.service.RentalService"
    cache-home="true"
    lookup-home-on-startup="true"
    resource-ref="true"
    home-interface="com.foo.service.RentalService"
    refresh-home-on-connect-failure="true">

Spring2.0 configuration adjustments in many areas, increasing more flexible, compact configuration, this paper two simple examples to demonstrate.
Configuring Apache as a data source connection pool, in previous versions of Spring 2.0, we can use similar to the following configuration:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE beans PUBLIC "- / / SPRING / / DTD BEAN / / EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<Bean
class = "org.apache.commons.dbcp.BasicDataSource"
destroy-method = "close">
<property name="driverClassName">
<value> org.gjt.mm.mysql.Driver </ value> </ property>
<property name="url">
<value> jdbc: mysql: / / 127.0.0.1:3306 / easyjf-bbs </ value> </ property>
<property name="username"> <value> root </ value> </ property>
<property name="password"> <value> mypass </ value> </ property>
</ Bean>
</ Beans>

In Spring2.0, you can put two labels <value> and <ref> parent <bean> tag as an attribute to define, which makes a more compact configuration file, as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE beans PUBLIC "- / / SPRING / / DTD BEAN / / EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<Bean
class = "org.apache.commons.dbcp.BasicDataSource"
destroy-method = "close">
<Property name = "driverClassName"
value = "org.gjt.mm.mysql.Driver" />
<Property name = "url"
value = "jdbc: mysql: / / 127.0.0.1:3306 / easyjf-bbs" />
<property name="username" value="root" />
<property name="password" value="mypass" />
</ Bean>
</ Beans>

In addition, Spring2.0 There is also a very practical parser, SimplePropertyNamespaceHandle, if the configuration file cited http://www.springframework.org/schema/p command space, will be used to deal with the Bean SimplePropertyNamespaceHandle definition Spring2.0 the Bean in a more simple way of setter injection configuration, as follows:
<? Xml version = "1.0" encoding = "UTF-8"?>
<Beans xmlns = "http://www.springframework.org/schema/beans"
xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns: p = "http://www.springframework.org/schema/p"
xsi: schemaLocation = "http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd">

<Bean
class = "org.apache.commons.dbcp.BasicDataSource" destroy-method = "close"
p: driverClassName = "org.gjt.mm.mysql.Driver"
p: url = "jdbc: mysql: / / 127.0.0.1:3306 / easyjf-bbs" p: username = "root" p: password = "mysql" />
</ Beans>

In the above configuration, use the p: url is the url directly into the BasicDataSource property value, you can use the p: url-ref attribute to refer to another Bean.
If, Spring2.0 before a DAO configuration:
<bean>
<property name="dataSource"> <ref bean="dataSource"/> </ property>
</ Bean>
Use short attribute, then it changed as follows:
<bean p:dataSource-ref="dataSource" />

Spring2.0 than previous versions of configuration more flexible, simple, and if the hand-written configuration, are more practical. Of course, there are a lot of the old configuration, such as MyEclipse and other development tools can identify, does not need our hands a little bit of the input configuration file, most of the new configuration tool can not identify, so please use discretion based on the actual situation.

相关文章
  • spring2.0 configuration of the new labeling applications 2010-07-09

    spring2.0 configuration of a new label application 2007-12-28 16:131, <util:constant/> Replaced before the acquisition by FieldRetrevingFactoryBean bean static constant FactoryBean! The use of old <bean> <property name="isolation"

  • Eclipse3.4 + Lomboz3.3 + Tomcat6.0 configuration and development of Web applications 2010-03-27

    Development of web applications using eclipse install configuration more complicated, according to their own learning experience, I will use eclipse + lomboz + tomcat specific installation and configuration process of developing web applications writ

  • struts2 + hibernate3.2 + spring2.0 instance configuration + Getting Started 2010-04-13

    eclipse3.2, myeclipse5.0, Jboss4.0.3, sql server2000 sp3 Principle of In the java enterprise applications, ejb powerful ejb configuration with the complex and difficult to learn as well known. But in the past and what we do? Just bite the bullet and

  • spring 2.0 + hibernate3.2 + struts 2.0 configuration records 2009-11-16

    struts2.0 + spring2.0 + hibernate 3.2 combined with the development of Web applications has brought a lot of improvements, more configuration parameters. The following describes how to combine the use of development projects struts2.0 + spring2.0 + h

  • Spring2.0 compressed package directory Description 2010-04-13

    1, Spring2.0 compressed package directory Description aspectj directory in the Spring framework to use aspectj source code and test program files. Aspectj is the first java application framework for the provision of AOP. dist directory is a Spring re

  • Spring2.0 jar package 2010-04-24

    1, Spring2.0 compressed package directory Description aspectj directory in the Spring framework to use aspectj source code and test program files. Aspectj is the first java application framework for the provision of AOP. dist directory is a Spring re

  • Xiang Jie spring2.0 the scope 2009-10-09

    How to use the spring scope: Java code <bean class ="spring.chapter2.maryGame.Role" scope="singleton"/> <bean scope="singleton"/> The scope here is used to configure the spring bean scope, it identifies scope bean

  • Spring2.0 the IOC Essays 2010-05-27

    View Spring2.0 in recent IOC, simply turn over source code find out. Spring provides a lightweight bean container formed the core of the two concepts, one is the bean container and the other is the bean factory (of course there are many other complex

  • Spring2.0 archive catalog description 2010-08-21

    1, Spring2.0 compressed catalog description aspectj directory in the Spring framework to use aspectj source code and test program files. Aspectj is the first to provide AOP java application framework. dist directory is a Spring release package, detai

  • SF1.2 + Spring2.0 + Hibernate3.2 2009-05-08

    Hanjing JAVA language JAVA study blog <<Java tutorial spring as the implementation gmail outgoing mail server-java source code | Home | TCP multiplayer chat applet>> Sep 20, 2008 JSF1.2 + Spring2.0 + Hibernate3.2 At the recent preparation of a

  • Spring2.0 comment implement the transaction management 2008-10-17

    Spring2.0 framework of the transaction there are two main categories: A coded transaction, it did not say. 2 Declarative transaction, say this. Declarative transaction there are three kinds of implementation methods: 1 (a) the first method, Transacti

  • struts2.0 + spring2.0 + hibernate3.1 complete process integration of multi-layer model of common errors (change) 2010-04-16

    Looking for entry-level, but the error solution for your reference. In this use MyEclipse6.0 as a programming environment, and truly comprehend after ssh, you know MyEclipse add spring and hibernate Support intention is automatically added to MyEclip

  • struts2.0 + spring2.0 + hibernate3.1 whole process of integration of multi-layer model of common errors (transfer) 2010-11-11

    Look for entry-level, but the bug is fixed for your reference. As used here MyEclipse6.0 programming environment, the real insight ssh, the will know to add spring and hibernate support for MyEclipse was intended only to spring and hibernate MyEclips

  • jBPM 4.0 Configuration Analysis 2010-03-29

    jbpm.jar contains a number of default configuration files, they can be imported into the user profile. In this way, the user can easily choose which features to include or exclude. And these configuration information also includes the implementation,

  • tomcat6.0 configuration data source 2008-11-26

    J2ee Initial Tomcat data source configuration 1. To find C: \ Program Files \ Apache Software Foundation \ Tomcat 6.0 \ conf the following context to modify configuration files are as follows <Context> <WatchedResource> WEB-INF/web.xml </ W

  • (Switch) Axis2 with the POJO to achieve 0 configuration WebService 2009-03-23

    Axis2 is a brand new WebService engine, this version is Axis1.x redesigned product. Axis2 not only supports SOAP1.1 and SOAP1.2, also integrates a very popular REST WebService, and also supports Spring, JSON technologies. These will be later in the s

  • struts2.1.6 + spring2.0 + hibernate3.2 be easily configured to 2010-03-19

    Recent study ssh2 integration of programming, by the way here, what next struts2 news updates, download a new version of the 2.1.8.1 version of struts2, using MyEclipse8.0 development, but the problem came along. MyEclipse8.0 in the built-in struts2

  • ext2.0 + struts2.1 + spring2.0 + jdbc framework 2010-03-09

    Using the framework of the: ext2.0 + struts2.1 + spring2.0 + jdbc, personal accounts system

  • Tomcat5.5 (6.0) configuration - more than a domain name - 2010-05-28

    August 7 Tomcat5.5 (6.0) configuration - and more binding domain and the virtual directories need to modify the configuration file: Tomcat 5.5 (6.0) \ conf \ server.xml server.xml changes as follows: (A) Multi-domain binding 1. If you want to bind th

  • [WebService Tutorial] to achieve 0 configuration with POJO WebService - 1 2010-07-04

    Axis2 WebService is a brand new engine, this version is Axis1.x redesigned product. Axis2 not only supports SOAP1.1 and SOAP1.2, also integrates a very popular REST WebService, and also supports Spring, JSON technologies. All will be explained later