spring <bean>的自动装配
来源:互联网 发布:seo工程师考证 编辑:程序博客网 时间:2024/04/29 01:20
1.不做任何操作
<bean id="serrvice" class="com.serviceImpl">
<propery name="dao" ref="Adao"/>
</bean>
<bean id="Adao" class="com.dao"/>
2.byName 根据属性名自动装配(default-autowire="byName"),此选项将检查容器并根据名字查找与属性完全一致的bean,并将与其属性自动装配;
<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.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
default-autowire="byName">
<bean id="serrvice" class="com.serviceImpl"/>
<bean id="Adao" class="com.dao"/>
</beans>
3
<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.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
default-autowire="byType">
<bean id="serrvice" class="com.serviceImpl"/>
<bean " class="com.dao"/>
</beans>
4
<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.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"
default-autowire="Constructor">
<bean id="serrvice" class="com.serviceImpl"/>
<bean " class="com.dao"/>
</beans>
- Spring Bean的装配 -- 自动装配
- [Spring]Bean的自动装配
- # Spring Bean 的自动装配
- spring bean的自动装配
- spring bean的自动装配
- Spring的自动装配Bean
- Spring bean的自动装配
- 【Spring】Bean的自动装配
- Spring Bean的自动装配
- Spring bean的自动装配
- spring <bean>的自动装配
- Spring Bean装配-自动装配
- Spring Bean--自动装配
- Spring Bean 自动装配
- spring自动装配bean
- 关于Spring的bean自动装配
- Spring XML配置自动装配的Bean
- spring中bean的自动装配(6)
- Cobbler部署指南之配置管理篇[下文]
- 抽奖规则分享
- php判断设备和微信
- 也想用git?命令太多眼花缭乱?四步带您快速上手开启装B之旅
- ubuntu16.04apt-get错误解决
- spring <bean>的自动装配
- 委托设计模式(即代理模式)
- Java 日期工具类
- maven下多环境配置文件、属性管理 & Spring使用@value初始化字段值
- Https总结
- 电气工程师能做电工么
- HTTP请求方法
- Json的基础到传值
- MYSQL修改编码