Spring Framework:4.3.14.RELEASE
p 命名空间
p 命名空间是简化 property 标签的
1 |
<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/beans |
包含引用属性:
1 |
<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/beans |
c 命名空间
c 命名空间是简化 constructor-arg 标签
1 |
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:c="http://www.springframework.org/schema/c" xsi:schemaLocation="http://www.springframework.org/schema/beans |
使用索引:
1 |
<bean id="foo" class="x.y.Foo" c:_0-ref="bar" c:_1-ref="baz"/> |
级联属性
1 |
<bean id="foo" class="foo.Bar"> |
depends-on属性
depends-on 属性用于显式声明依赖初始化的先后顺序
1 |
<bean id="beanOne" class="ExampleBean" depends-on="manager"/> |
上述说明在实例化 beanOne 前需要先实例化 manager
1 |
<bean id="beanOne" class="ExampleBean" depends-on="manager,accountDao"> |
lazy-init属性
容器启动时默认对 Bean 进行初始化。 lazy-init 可以对 Bean 设置延迟初始化,当第一次访问时再去初始化。
1 |
<bean id="lazy" class="com.foo.ExpensiveToCreateBean" lazy-init="true"/> |
还可以批量设置启用:
1 |
<beans default-lazy-init="true"> |
近期评论