在Spring1.x系列中,bean的配置文件使用DTD,没有namespace的分隔。
<?
xml version
=
"
1.0
"
encoding
=
"
UTF-8
"
?>
<! DOCTYPE beans PUBLIC " -//SPRING//DTD BEAN//EN "
" http://www.springframework.org/dtd/spring-beans.dtd " >
< beans >
</ beans >
<! DOCTYPE beans PUBLIC " -//SPRING//DTD BEAN//EN "
" http://www.springframework.org/dtd/spring-beans.dtd " >
< beans >
</ beans >
2.0的一个非常大的改进是引入了XML Schema的namespace,因而可以将bean的配置文件做大幅度的简化。
<?
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:aop = " http://www.springframework.org/schema/aop " xmlns:tx = " http://www.springframework.org/schema/tx "
xsi:schemaLocation = " http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http: // www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http: // www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd ">
</ beans >
< beans xmlns = " http://www.springframework.org/schema/beans " xmlns:xsi = " http://www.w3.org/2001/XMLSchema-instance "
xmlns:aop = " http://www.springframework.org/schema/aop " xmlns:tx = " http://www.springframework.org/schema/tx "
xsi:schemaLocation = " http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http: // www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http: // www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd ">
</ beans >
这些简化包括了对bean属性的各种简化,AOP配置的简化,事务配置的简化,JNDI配置的简化等方面。