Spring 控制反转的几种方式
来源:互联网 发布:自己怎么注册淘宝店铺 编辑:程序博客网 时间:2024/05/13 04:06
<?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/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="PersonDaoBean" class="_1.dao.impl.PersonDaoBean"></bean>
<bean id="PersonServiceBean" class="_1.service.impl.PersonServiceBean">
<property name="name" value="kenqq"></property>
<property name="age" value="22"></property>
<property name="personDao" ref="PersonDaoBean"></property>
</bean>
</beans>
2.构造器注入 (略
3.注释注入
...
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:annotation-config />
<bean id="PersonDaoBean" class="_1.dao.impl.PersonDaoBean"></bean>
<bean id="PersonServiceBean" class="_1.service.impl.PersonServiceBean">
<property name="name" value="kenqq"></property>
<property name="age" value="22"></property>
<!-- <property name="personDao" ref="PersonDaoBean"></property>-->
</bean>
</beans>
在被控制类的接口 setter上面插入: @Resource
4.自动扫描注入
在dao类上:@Repository
Server类上:@Service("p") (这个就是bean 名
当然 控制类的接口 setter上面插入: @Resource
- Spring 控制反转的几种方式
- Spring的控制反转的三种方式
- spring的控制反转
- Spring的控制反转
- spring的反转控制
- Spring的控制反转
- Spring的控制反转
- 字符串反转实现的几种方式
- 字符串反转的几种方式
- python反转字符串的几种方式
- spring依赖注入(控制反转)的多种方式
- Spring依赖注入/控制反转的四种方式以及特殊字符的注入
- spring四种依赖注入方式 ( 依赖注入DI+ 控制反转IOC的原理)
- Spring实现控制反转(IOC)的三种方式(零)——理解IOC
- Spring实现控制反转(IOC)的三种方式(一)——属性注入
- Spring实现控制反转(IOC)的三种方式(三)——自动装配
- spring IOC控制反转及IOC实现的三种方式和bean标签使用
- Spring实现控制反转(IOC)的三种方式(二)——构造器注入
- 学习
- 城里城外看SSDT
- 中国的教育
- struts2中,一个表单里有多个提交按钮的处理办法
- 求近似根的算法-matlab实现
- Spring 控制反转的几种方式
- ODBC获取记录记录数
- 远程执行SQL或远程调用存储过程
- 利用GDB和Bochs调试内核源代码
- 利用crosstool-ng-1.14.0制作交叉编译工具链
- fcgi-2.4.1 fastcgi开发包 make编译出错
- Struts2标签实现for循环
- 我的Android开发环境搭建
- python实现一个web服务器识别工具