本篇博文的目录: 一:前言 二:spring的配置文件 三:依赖的第三方库.使用技术.代码布局 四:Document实现 五:获取Element的实现 六:解析Element元素 七:Bean创造器 八:Ioc容器的创建 九:总结 一:前言: Spring作为Bean的管理容器,在我们的项目构建中发挥了举足轻重的作用,尤其是控制反转(IOC)和依赖(DI)注入的特性,将对象的创建完全交给它来实现,当我们把与其他框架进行整合时,比如与Mybatis整合,可以把sqlMapClientTemplat…
一.当spring解析完配置文件名的占位符后,就开始refresh容器 @Override public void refresh() throws BeansException, IllegalStateException { synchronized (this.startupShutdownMonitor) { // Prepare this context for refreshing. //设置了启动时间,激活状态设为true,初始化一些propertySource //初始化的时候啥…
import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class TestAction { public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationC…
我们通过一个小案例来看xml解析过程. 1. 导包 <dependencies> <!-- xml解析工具 --> <dependency> <groupId>dom4j</groupId> <artifactId>dom4j</artifactId> <version>1.6.1</version> </dependency> <!-- 常用工具包 --> <depe…
本节主要内容: 一.Spring 通过XML配置文件形式来AOP 来实现前置,环绕,异常通知     1. Spring AOP  前置通知 XML配置使用案例     2. Spring AOP  环绕通知 XML配置使用案例     3. Spring AOP  抛出异常后通知 XML配置使用案例     4. Spring AOP  返回后通知 XML配置使用案例     5. Spring AOP  后通知  XML配置使用案例 二.Spring 通过注解形式来AOP 来实现前置,环绕,…
在项目中我们经常需要将配置信息写在配置文件中,而XML配置文件是常用的格式. 下面将介绍如何通过jdom来读取xml配置文件信息. 配置文件信息 <?xml version="1.0" encoding="UTF-8"?> <config> <base-config> <stringValue>Hello world</stringValue> <integerValue>8</integ…
接上篇,spring读取prperties配置文件(1),这一篇主要讲述spring如何用annotation的方式去读取自定义的配置文件. 这里我先定义好属性文件"user.properties". user.name=bingyulei user.description=没有什么好描述的 然后再spring的配置文件中applicationContext.xml加入如下配置,这里我配置文件就放到classpath下,可以运行junit测试 <?xml version=&quo…
博客地址http://www.cnblogs.com/shizhongtao/p/3438431.html 属性文件命名是*.properties,在java中,用类java.util.Properties来处理,例如我创建文件my.properties,然后加入属性 filename=你好path=D\:\\app 那么在java中就可以这样读取属性 InputStream in=App.class.getResourceAsStream ("/my.properties"); Pr…
eclipse编写spring等xml配置文件时只有<bean>.<context>等有提示,其他标签都没有提示 这时就需要做以下两步操作(下面以事务管理标签为例) 1,添加命名空间“xmlns:tx”   xmlns:tx="http://www.springframework.org/schema/tx"   2,在“xsi:schemaLocation”里新增xsd文件路径 http://www.springframework.org/schema/tx…
Person类中的各种属性写法如下: package com.swift.person; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Properties; public class Person { //普通字符串 private String name; //字符串数组 private String[] arr; //字符串列表 private List<Stri…