Spring applicationContext.xml文件解析
2015-07-17 09:34
253 查看
ssh的框架大部分就是在代码中解析xml文件,然后xml文件中配置对应其他关系,话不多说,show code:
所需头文件必不可少,所有的bean都写在这里:
定义了bean的ID和类
代码中加载xml文件,获取bean,注意getBean();方法中的参数要和xml文件中ID保持一致
未完待续
所需头文件必不可少,所有的bean都写在这里:
<?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"> </beans>
定义了bean的ID和类
<bean id="hd" class="com.btlh.zz.hb.spring.HelloWorld"></bean>
代码中加载xml文件,获取bean,注意getBean();方法中的参数要和xml文件中ID保持一致
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); HelloWorld hd = (HelloWorld)context.getBean("hd"); hd.hello();
未完待续
相关文章推荐
- iOS开发 - CoreData框架 数据持久化
- objc_setAssociatedObject获取cell上button对应所在的行
- iOS开发者有价值的工具集
- 高效开发Android App的10个建议
- 一枚Android拦截马简要分析
- Android高效的应用程序开发工具集1---ant构建一个简单的Android工程
- android 开发错误解决(一)
- Android Studio 使用笔记:Git 的配置和第一次提交到仓库
- android 4.3之前的版本 播放hls获取不到总时长的原因
- Android中Listview(二)--圆角listview
- .NET微信公众号开发-6.0模板消息
- Android仿虾米音乐播放器之service
- [MyBatis]mapperLocations属性通配符的使用
- Android studio 自动排版
- 按键精灵微信群内加好友
- 使用Android Studio查看Android 5.x源码
- WebGL 在 OpenGL ES 指令 iOS 在 C 分歧版指令分析
- Android studio 下载安装
- ios开发中,关于javascript直接调用oc代码而非通过改变url回调方式
- IOS atomic与nonatomic,assign,copy与retain的定义和区别