SPRING IOC注入方式过程解析
作者:魏晋南北朝 时间:2023-10-11 12:59:13
这篇文章主要介绍了SPRING IOC注入方式过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Spring IOC注入的方法主要有两种
1:设值注入
2:构造注入
简单来说一个是调用set方法设值,一个是通过构造函数设值
Spring-ioc.xml
<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "http://www.springframework.org/schema/beans"
xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation= "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
default-init-method= "init" default-destroy-method= "destroy">
<!--
<bean id="InjectionService" class="Main.InjectionServiceImpl">
<property name="injectionDAO" ref="InjectionDAO"></property>
</bean>
-->
<bean id="InjectionService" class="Main.InjectionServiceImpl">
<constructor-arg name="injectionDAO" ref="InjectionDAO"></constructor-arg>
</bean>
<bean id="InjectionDAO" class= "Main.InjectionDAOImpl"> </bean>
</beans>
来源:https://www.cnblogs.com/wjune-0405/p/12148750.html
标签:SPRING,IOC,注入
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
java 获取当前时间的三种方法
2022-10-11 21:54:04
Android热修复Tinker接入及源码解读
2023-11-14 09:27:18
![](https://img.aspxhome.com/file/2023/9/138629_0s.jpg)
Springboot笔记之热部署及不生效的解决方案
2023-11-03 02:40:00
![](https://img.aspxhome.com/file/2023/9/83569_0s.png)
你什么是Elastic Stack(ELK)
2022-12-02 20:12:43
![](https://img.aspxhome.com/file/2023/2/65182_0s.jpg)
SpringCloud超详细讲解负载均衡组件Ribbon源码
2021-06-17 18:39:47
![](https://img.aspxhome.com/file/2023/6/86866_0s.png)
Android Java try catch 失效问题及解决
2023-06-17 17:07:33
Springboot集成JSR303参数校验的方法实现
2023-02-06 06:34:44
![](https://img.aspxhome.com/file/2023/7/72377_0s.png)
Android利用OpenGLES绘制天空盒实例教程
2023-11-19 16:07:27
![](https://img.aspxhome.com/file/2023/9/138389_0s.gif)
Android UI设计系列之自定义TextView属性实现带下划线的文本框(4)
2022-08-11 11:03:29
![](https://img.aspxhome.com/file/2023/2/137862_0s.png)
解析Android开发中多点触摸的实现方法
2021-12-07 11:20:35
淘宝IP地址库采集器c#代码
2022-01-15 22:42:33
![](https://img.aspxhome.com/file/2023/6/77266_0s.png)
Android笔记之:App应用之启动界面SplashActivity的使用
2023-03-21 19:05:56
![](https://img.aspxhome.com/file/2023/1/137501_0s.jpg)
Android编程之重力感应用法分析
2021-09-04 19:49:35
Android自定义弹框Dialog效果
2022-09-21 02:40:41
![](https://img.aspxhome.com/file/2023/1/137301_0s.jpg)
详解Java如何实现一个像String一样不可变的类
2022-01-12 16:17:11
![](https://img.aspxhome.com/file/2023/0/113390_0s.jpg)
Android获取SD卡路径及SDCard内存的方法
2021-12-30 17:04:58
LRU缓存替换策略及C#实现方法分享
2021-08-27 04:20:49
![](https://img.aspxhome.com/file/2023/4/111254_0s.png)
C语言实现稀疏矩阵
2023-04-17 15:00:45
![](https://img.aspxhome.com/file/2023/5/120805_0s.jpg)
详解Java使用Pipeline对Redis批量读写(hmset&hgetall)
2023-11-17 15:17:24
C#生成word记录实例解析
2023-09-10 00:17:33