spring的配置
来源:互联网 发布:java雷霆战机开发视频 编辑:程序博客网 时间:2024/05/21 16:08
一、导入相关jar包
二、IoC控制反转
2.1、在applicationContext.xml中
<bean id="A" class="A类的完整路径名"></bean>
2.2、ApplicationContext context = new ClassPathXmlApplicationContext("包名+applicationContext.xml");
A a = (A)context.getBean("A"); //这就得到了A类的对象a,并且调用了A类无参的构造方法,接下来就可以用对象名调用方法。
context.close();
三、依赖注入
<bean id="person" class="完整路径名">
<!--
property就是代表属性
name为属性,value是值
-->
<property name="pid" value="5"></property>
<!--
ref是引用类型
-->
<property name="student">
<ref bean="student"/>
</property>
</bean>
二、IoC控制反转
2.1、在applicationContext.xml中
<bean id="A" class="A类的完整路径名"></bean>
2.2、ApplicationContext context = new ClassPathXmlApplicationContext("包名+applicationContext.xml");
A a = (A)context.getBean("A"); //这就得到了A类的对象a,并且调用了A类无参的构造方法,接下来就可以用对象名调用方法。
context.close();
三、依赖注入
<bean id="person" class="完整路径名">
<!--
property就是代表属性
name为属性,value是值
-->
<property name="pid" value="5"></property>
<!--
ref是引用类型
-->
<property name="student">
<ref bean="student"/>
</property>
</bean>
阅读全文
0 0
- spring-spring的配置
- spring bean的配置
- 配置Spring的方法
- Spring 事务管理的配置
- spring+hibernate的配置
- spring定时器的配置
- 配置spring的事务管理
- Spring Security的配置
- Spring的事务配置
- spring的 PropertyPlaceholderConfigurer配置
- spring的配置
- Spring常用的配置
- spring的AOP配置
- Spring的dataSource配置
- spring 事务管理的配置
- Spring的AOP配置
- spring的maven配置
- spring+activemq的配置
- 理解生产者和消费者,两种实现方式
- CodeForces 670 E.Correct Bracket Sequence Editor(链表)
- html引入css外部样式表
- iOS 设备参数
- Android Fragment 真正的完全解析(上)
- spring的配置
- 【转】JDBC常见面试题
- JS中几种获取对象宽度和高度的区别
- Linux下的MySQL入门
- docker系列一: docker安装mysql
- opencv访问图片中像素的方法(三)——动态地址计算
- [Hive]HiveServer2概述
- Android Fragment 真正的完全解析(下)
- android阿里面试题锦集