<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- 启动 @AspectJ的支持-->
<aop:aspectj-autoproxy/>
<!-- 声明日志切面 -->
<bean id="logAspect" class="com.lovo.aspect.LogAspect"></bean>
<!-- 将简单java对象声明在容器中,容器启动的时候创建 -->
<bean id="user" class="com.lovo.bean.UserInfoT" >
<property name="userName" value="张飞"></property>
<property name="password" value="123"></property>
</bean>
<!-- 设值注入
<bean id="userService" class="com.lovo.service.impl.UserServiceImpl">
<property name="dao" ref="userDao"></property>
</bean> -->
<!-- 构造注入 -->
<bean id="userService" class="com.lovo.service.impl.UserServiceImpl">
<!-- index属性表示该类的对应属性的顺序,从零开始,ref表引用 -->
<constructor-arg index="0" ref="userDao"></constructor-arg>
</bean>
<bean id="userDao" class="com.lovo.dao.impl.UserDaoImpl"></bean>
<bean id="language" class="com.lovo.bean.LanguageBean">
<property name="list">
<list>
<value>hello</value>
<value>world</value>
</list>
</property>
<property name="mySet">
<set>
<value>hello1</value>
<value>world1</value>
</set>
</property>
<property name="myMap">
<map>
<entry key="aa" ><value>helloMap</value></entry>
<entry key="bb" value="worldMap"></entry>
</map>
</property>
<property name="pro">
<props>
<prop key="aaa" >helloMap</prop>
<prop key="bbb" >worldMap</prop>
</props>
</property>
</bean>
</beans>
Spring Ioc set注入
最新推荐文章于 2022-05-25 18:27:10 发布