【皇甫】☀IOC和AOP的拓展实例
<!--构造器注入 -->
<bean id="user1" class="cn.happy.entity.User">
<constructor-arg index="0" type="java.lang.String" value="lxl"></constructor-arg>
<constructor-arg index="1" type="java.lang.String" value="lxl@163.com"></constructor-arg>
</bean>
Test:
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); User user=(User)ctx.getBean("user1"); System.out.println(user.getEmail());
<!-- set方法注入 -->
<bean id="user2" class="cn.happy.entity.User">
<!-- 使用property -->
<property name="username" value="张靓颖"></property>
</bean>
******************************************************待续