- 浏览: 84237 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
lvyanglin:
dongxurr123 写道帅哥 DependencyInje ...
真正意义上的spring环境中的单元测试方案spring-test与mokito完美结合 -
dongxurr123:
帅哥 DependencyInjectionAsMockito ...
真正意义上的spring环境中的单元测试方案spring-test与mokito完美结合 -
Aceslup:
怎么更换都不行呢。楼主能提供jar吗?
tomcat的session存入redis配置 -
403577706:
sudo apt-get build-dep #(packag ...
sudo apt-get -f install
在很多情况下,我们需要为系统提供可配置化支持,简单的做法可以直接基于Spring的标准Bean来配置,但配置较为复杂或者需要更多丰富控制的时候,会显得非常笨拙。一般的做法会用原生态的方式去解析定义好的xml文件,然后转化为配置对象,这种方式当然可以解决所有问题,但实现起来比较繁琐,特别是是在配置非常复杂的时候,解析工作是一个不得不考虑的负担。Spring提供了可扩展Schema的支持,这是一个不错的折中方案,完成一个自定义配置一般需要以下步骤:
设计配置属性和JavaBean
编写XSD文件
编写NamespaceHandler和BeanDefinitionParser完成解析工作
编写spring.handlers和spring.schemas串联起所有部件
在Bean文件中应用
下面结合一个小例子来实战以上过程
1)设计配置属性和JavaBean
首先当然得设计好配置项,并通过JavaBean来建模,本例中需要配置People实体,配置属性name和age(id是默认需要的)
public class People {
private String id;
private String name;
private Integer age;
}
public class People {
private String id;
private String name;
private Integer age;
}
2)编写XSD文件
为上一步设计好的配置项编写XSD文件,XSD是schema的定义文件,配置的输入和解析输出都是以XSD为契约,本例中XSD如下:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns="http://blog.csdn.net/cutesource/schema/people"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
targetNamespace="http://blog.csdn.net/cutesource/schema/people"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" />
<xsd:element name="people">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="age" type="xsd:int" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns="http://blog.csdn.net/cutesource/schema/people"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
targetNamespace="http://blog.csdn.net/cutesource/schema/people"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" />
<xsd:element name="people">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="age" type="xsd:int" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
关于xsd:schema的各个属性具体含义就不作过多解释,可以参见http://www.w3school.com.cn/schema/schema_schema.asp
<xsd:element name="people">对应着配置项节点的名称,因此在应用中会用people作为节点名来引用这个配置
<xsd:attribute name="name" type="xsd:string" />和<xsd:attribute name="age" type="xsd:int" />对应着配置项people的两个属性名,因此在应用中可以配置name和age两个属性,分别是string和int类型
完成后需把xsd存放在classpath下,一般都放在META-INF目录下(本例就放在这个目录下)
3)编写NamespaceHandler和BeanDefinitionParser完成解析工作
下面需要完成解析工作,会用到NamespaceHandler和BeanDefinitionParser这两个概念。具体说来NamespaceHandler会根据schema和节点名找到某个BeanDefinitionParser,然后由BeanDefinitionParser完成具体的解析工作。因此需要分别完成NamespaceHandler和BeanDefinitionParser的实现类,Spring提供了默认实现类NamespaceHandlerSupport和AbstractSingleBeanDefinitionParser,简单的方式就是去继承这两个类。本例就是采取这种方式:
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
public class MyNamespaceHandler extends NamespaceHandlerSupport {
public void init() {
registerBeanDefinitionParser("people", new PeopleBeanDefinitionParser());
}
}
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
public class MyNamespaceHandler extends NamespaceHandlerSupport {
public void init() {
registerBeanDefinitionParser("people", new PeopleBeanDefinitionParser());
}
}
其中registerBeanDefinitionParser("people", new PeopleBeanDefinitionParser());就是用来把节点名和解析类联系起来,在配置中引用people配置项时,就会用PeopleBeanDefinitionParser来解析配置。PeopleBeanDefinitionParser就是本例中的解析类:
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
public class PeopleBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
protected Class getBeanClass(Element element) {
return People.class;
}
protected void doParse(Element element, BeanDefinitionBuilder bean) {
String name = element.getAttribute("name");
String age = element.getAttribute("age");
String id = element.getAttribute("id");
if (StringUtils.hasText(id)) {
bean.addPropertyValue("id", id);
}
if (StringUtils.hasText(name)) {
bean.addPropertyValue("name", name);
}
if (StringUtils.hasText(age)) {
bean.addPropertyValue("age", Integer.valueOf(age));
}
}
}
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
public class PeopleBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
protected Class getBeanClass(Element element) {
return People.class;
}
protected void doParse(Element element, BeanDefinitionBuilder bean) {
String name = element.getAttribute("name");
String age = element.getAttribute("age");
String id = element.getAttribute("id");
if (StringUtils.hasText(id)) {
bean.addPropertyValue("id", id);
}
if (StringUtils.hasText(name)) {
bean.addPropertyValue("name", name);
}
if (StringUtils.hasText(age)) {
bean.addPropertyValue("age", Integer.valueOf(age));
}
}
}
其中element.getAttribute就是用配置中取得属性值,bean.addPropertyValue就是把属性值放到bean中。
4)编写spring.handlers和spring.schemas串联起所有部件
上面几个步骤走下来会发现开发好的handler与xsd还没法让应用感知到,就这样放上去是没法把前面做的工作纳入体系中的,spring提供了spring.handlers和spring.schemas这两个配置文件来完成这项工作,这两个文件需要我们自己编写并放入META-INF文件夹中,这两个文件的地址必须是META-INF/spring.handlers和META-INF/spring.schemas,spring会默认去载入它们,本例中spring.handlers如下所示:
http\://blog.csdn.net/cutesource/schema/people=study.schemaExt.MyNamespaceHandler
以上表示当使用到名为"http://blog.csdn.net/cutesource/schema/people"的schema引用时,会通过study.schemaExt.MyNamespaceHandler来完成解析
spring.schemas如下所示:
http\://blog.csdn.net/cutesource/schema/people.xsd=META-INF/people.xsd
以上就是载入xsd文件
5)在Bean文件中应用
到此为止一个简单的自定义配置以完成,可以在具体应用中使用了。使用方法很简单,和配置一个普通的spring bean类似,只不过需要基于我们自定义schema,本例中引用方式如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cutesource="http://blog.csdn.net/cutesource/schema/people"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://blog.csdn.net/cutesource/schema/people http://blog.csdn.net/cutesource/schema/people.xsd">
<cutesource:people id="cutesource" name="袁志俊" age="27"/>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cutesource="http://blog.csdn.net/cutesource/schema/people"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://blog.csdn.net/cutesource/schema/people http://blog.csdn.net/cutesource/schema/people.xsd">
<cutesource:people id="cutesource" name="袁志俊" age="27"/>
</beans>
其中xmlns:cutesource="http://blog.csdn.net/cutesource/schema/people"是用来指定自定义schema,xsi:schemaLocation用来指定xsd文件。<cutesource:people id="cutesource" name="zhijun.yuanzj" age="27"/>是一个具体的自定义配置使用实例。
最后就可以在具体程序中使用基本的bean载入方式来载入我们的自定义配置对象了,如:
ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml");
People p = (People)ctx.getBean("cutesource");
System.out.println(p.getId());
System.out.println(p.getName());
System.out.println(p.getAge());
ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml");
People p = (People)ctx.getBean("cutesource");
System.out.println(p.getId());
System.out.println(p.getName());
System.out.println(p.getAge());
会输出:
cutesource
袁志俊
27
以上就是一个基于Spring可扩展Schema提供自定义配置支持实战过程,一些复杂应用和技巧还有待挖掘
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cutesource/archive/2010/09/05/5864562.aspx
设计配置属性和JavaBean
编写XSD文件
编写NamespaceHandler和BeanDefinitionParser完成解析工作
编写spring.handlers和spring.schemas串联起所有部件
在Bean文件中应用
下面结合一个小例子来实战以上过程
1)设计配置属性和JavaBean
首先当然得设计好配置项,并通过JavaBean来建模,本例中需要配置People实体,配置属性name和age(id是默认需要的)
public class People {
private String id;
private String name;
private Integer age;
}
public class People {
private String id;
private String name;
private Integer age;
}
2)编写XSD文件
为上一步设计好的配置项编写XSD文件,XSD是schema的定义文件,配置的输入和解析输出都是以XSD为契约,本例中XSD如下:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns="http://blog.csdn.net/cutesource/schema/people"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
targetNamespace="http://blog.csdn.net/cutesource/schema/people"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" />
<xsd:element name="people">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="age" type="xsd:int" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
xmlns="http://blog.csdn.net/cutesource/schema/people"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
targetNamespace="http://blog.csdn.net/cutesource/schema/people"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:import namespace="http://www.springframework.org/schema/beans" />
<xsd:element name="people">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="age" type="xsd:int" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
关于xsd:schema的各个属性具体含义就不作过多解释,可以参见http://www.w3school.com.cn/schema/schema_schema.asp
<xsd:element name="people">对应着配置项节点的名称,因此在应用中会用people作为节点名来引用这个配置
<xsd:attribute name="name" type="xsd:string" />和<xsd:attribute name="age" type="xsd:int" />对应着配置项people的两个属性名,因此在应用中可以配置name和age两个属性,分别是string和int类型
完成后需把xsd存放在classpath下,一般都放在META-INF目录下(本例就放在这个目录下)
3)编写NamespaceHandler和BeanDefinitionParser完成解析工作
下面需要完成解析工作,会用到NamespaceHandler和BeanDefinitionParser这两个概念。具体说来NamespaceHandler会根据schema和节点名找到某个BeanDefinitionParser,然后由BeanDefinitionParser完成具体的解析工作。因此需要分别完成NamespaceHandler和BeanDefinitionParser的实现类,Spring提供了默认实现类NamespaceHandlerSupport和AbstractSingleBeanDefinitionParser,简单的方式就是去继承这两个类。本例就是采取这种方式:
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
public class MyNamespaceHandler extends NamespaceHandlerSupport {
public void init() {
registerBeanDefinitionParser("people", new PeopleBeanDefinitionParser());
}
}
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
public class MyNamespaceHandler extends NamespaceHandlerSupport {
public void init() {
registerBeanDefinitionParser("people", new PeopleBeanDefinitionParser());
}
}
其中registerBeanDefinitionParser("people", new PeopleBeanDefinitionParser());就是用来把节点名和解析类联系起来,在配置中引用people配置项时,就会用PeopleBeanDefinitionParser来解析配置。PeopleBeanDefinitionParser就是本例中的解析类:
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
public class PeopleBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
protected Class getBeanClass(Element element) {
return People.class;
}
protected void doParse(Element element, BeanDefinitionBuilder bean) {
String name = element.getAttribute("name");
String age = element.getAttribute("age");
String id = element.getAttribute("id");
if (StringUtils.hasText(id)) {
bean.addPropertyValue("id", id);
}
if (StringUtils.hasText(name)) {
bean.addPropertyValue("name", name);
}
if (StringUtils.hasText(age)) {
bean.addPropertyValue("age", Integer.valueOf(age));
}
}
}
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
public class PeopleBeanDefinitionParser extends AbstractSingleBeanDefinitionParser {
protected Class getBeanClass(Element element) {
return People.class;
}
protected void doParse(Element element, BeanDefinitionBuilder bean) {
String name = element.getAttribute("name");
String age = element.getAttribute("age");
String id = element.getAttribute("id");
if (StringUtils.hasText(id)) {
bean.addPropertyValue("id", id);
}
if (StringUtils.hasText(name)) {
bean.addPropertyValue("name", name);
}
if (StringUtils.hasText(age)) {
bean.addPropertyValue("age", Integer.valueOf(age));
}
}
}
其中element.getAttribute就是用配置中取得属性值,bean.addPropertyValue就是把属性值放到bean中。
4)编写spring.handlers和spring.schemas串联起所有部件
上面几个步骤走下来会发现开发好的handler与xsd还没法让应用感知到,就这样放上去是没法把前面做的工作纳入体系中的,spring提供了spring.handlers和spring.schemas这两个配置文件来完成这项工作,这两个文件需要我们自己编写并放入META-INF文件夹中,这两个文件的地址必须是META-INF/spring.handlers和META-INF/spring.schemas,spring会默认去载入它们,本例中spring.handlers如下所示:
http\://blog.csdn.net/cutesource/schema/people=study.schemaExt.MyNamespaceHandler
以上表示当使用到名为"http://blog.csdn.net/cutesource/schema/people"的schema引用时,会通过study.schemaExt.MyNamespaceHandler来完成解析
spring.schemas如下所示:
http\://blog.csdn.net/cutesource/schema/people.xsd=META-INF/people.xsd
以上就是载入xsd文件
5)在Bean文件中应用
到此为止一个简单的自定义配置以完成,可以在具体应用中使用了。使用方法很简单,和配置一个普通的spring bean类似,只不过需要基于我们自定义schema,本例中引用方式如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cutesource="http://blog.csdn.net/cutesource/schema/people"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://blog.csdn.net/cutesource/schema/people http://blog.csdn.net/cutesource/schema/people.xsd">
<cutesource:people id="cutesource" name="袁志俊" age="27"/>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cutesource="http://blog.csdn.net/cutesource/schema/people"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://blog.csdn.net/cutesource/schema/people http://blog.csdn.net/cutesource/schema/people.xsd">
<cutesource:people id="cutesource" name="袁志俊" age="27"/>
</beans>
其中xmlns:cutesource="http://blog.csdn.net/cutesource/schema/people"是用来指定自定义schema,xsi:schemaLocation用来指定xsd文件。<cutesource:people id="cutesource" name="zhijun.yuanzj" age="27"/>是一个具体的自定义配置使用实例。
最后就可以在具体程序中使用基本的bean载入方式来载入我们的自定义配置对象了,如:
ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml");
People p = (People)ctx.getBean("cutesource");
System.out.println(p.getId());
System.out.println(p.getName());
System.out.println(p.getAge());
ApplicationContext ctx = new ClassPathXmlApplicationContext("application.xml");
People p = (People)ctx.getBean("cutesource");
System.out.println(p.getId());
System.out.println(p.getName());
System.out.println(p.getAge());
会输出:
cutesource
袁志俊
27
以上就是一个基于Spring可扩展Schema提供自定义配置支持实战过程,一些复杂应用和技巧还有待挖掘
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cutesource/archive/2010/09/05/5864562.aspx
发表评论
-
tomcat的session存入redis配置
2014-11-18 19:00 16265在java web环境中一般都 ... -
一致性hash算法实现技巧
2014-11-16 10:13 1245在分布式缓存或者存储系统中经常都会用到hash算法,最早的时候 ... -
开发小知识
2012-12-04 16:12 721rpm -qa | grep java 查找java rpm ... -
struts2 源代码
2011-04-25 22:34 1284SVN 签出源码 Struts Spring ... -
openssl 建证书
2011-04-23 09:19 12261、产生CA私钥与CA证书 openssl genrsa ... -
证书方面要注意的
2011-03-27 01:01 977Java自带的keytool工具是个密钥和证书管理工具。它使用 ... -
证书类型分类
2011-03-23 13:22 2542证书主要的文件类型和协议有: PEM、DER、PFX、JKS、 ... -
加密解密
2011-03-22 22:28 843本文主要谈一下密码学中的加密和数字签名,以及其在java中如何 ... -
MAVEN 常用命令
2011-03-05 15:51 839一、Maven概述 Maven是一个项目管理工具,它包含了一个 ... -
陈科博客
2010-11-10 09:30 780lingqi1818.iteye.com -
spring 学习
2010-11-06 23:44 791http://doc.javanb.com/spring-fr ... -
java 内存 栈和堆
2010-09-27 19:39 698Java 把内存划分成两种 ... -
ubuntu 字符集修改
2010-08-20 13:25 6905在Widnows XP下的FTP服务器中有中文文件名 ,今天使 ... -
log4j举例
2010-08-14 18:28 760一、前言: log4j 是一个开放源码项目,是广泛 ... -
spring2.0 AOP举例
2010-07-30 01:30 681spring 2.0 aop 配置----解决 CGLIB2 ... -
eclipse 快捷键使用大全
2010-07-26 11:38 664(1)Ctrl+M切换窗口的大 ... -
cas client使用指南
2010-03-17 14:56 24352008-02-27 JA-SIG(CAS)学 ... -
cas 服务器端的配置
2010-03-14 13:26 1146.修改cas/webapp/WEB-INF/deployerC ... -
java时间的处理
2010-03-11 17:20 7532008-05-28 java中字符串转换成时间格式总结 关键 ... -
java web编码处理一般问题
2009-12-22 14:01 9091. 在struts2里面,最好将所有字符都设成utf-8。 ...
相关推荐
## Spring入门学习 首先认识下Spring的结构 ![架构图](http://www.ibm.com/developerworks/cn/java/j-lo-spring-principle/image001.gif) 然后我们皆可以写我们的demo了 ### 我们的Bean类 对于bean的理解,希望...
Spring2.5和Hibernate3集成 采用声明式事务 1.声明式事务的配置 * 配置sessionFactory ... 2.http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
主要包括Spring的IoC、AOP(注释注入、Schema注入、与AspectJ的集成、有接口和无接口的实现的界面编程)、中间数据访问层(编程事事务管理、声明式事务管理、与Hibernate的集成、与JDO的集成、与JTA的集成、纯Spring...
第12章:讲解了如何在Spring中集成Hibernate、myBatis等数据访问框架,同时,读者还将学习到ORM框架的混用和DAO层设计的知识。 第13章:本章重点对在Spring中如何使用Quartz进行任务调度进行了讲解,同时还涉及...
Spring容器高级主题 第6章 Spring AOP基础 第7章 基于@AspectJ和Schema的 第7章 AOP 第3篇 数据库访问 第8章 Spring对DAO的支持 第9章 Spring的事务管理 第10章 使用Spring JDBC访问数据库 ...
Spring容器高级主题 第6章 Spring AOP基础 第7章 基于@AspectJ和Schema的 第7章 AOP 第3篇 数据库访问 第8章 Spring对DAO的支持 第9章 Spring的事务管理 第10章 使用Spring JDBC访问数据库 ...
Spring容器高级主题 第6章 Spring AOP基础 第7章 基于@AspectJ和Schema的 第7章 AOP 第3篇 数据库访问 第8章 Spring对DAO的支持 第9章 Spring的事务管理 第10章 使用Spring JDBC访问数据库 ...
主要给大家介绍了关于Spring中XML schema扩展机制的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
第12章:讲解了如何在Spring中集成Hibernate、myBatis等数据访问框架,同时,读者还将学习到ORM框架的混用和DAO层设计的知识。 第13章:本章重点对在Spring中如何使用Quartz进行任务调度进行了讲解,同时还涉及...
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop=...
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx=...
这个是spring AOP 的一个小Demo 通过Schema-base添加前置通知和后置通知 结合博客 可以学习一下
Spring学习 阅读Spring源码 目录 测试Spring中扩展模式来定义Bean 添加依赖: <groupId>top.ningg.learn.spring <artifactId>spring-learn <version>1.0-SNAPSHOT 配置文件中,添加配置: <beans xmlns=...
项目目的在理解 Spring 系统结构、实现原理的基础上,自己动手写一个实现Spring核心功能的框架,以达到学习的目的。项目入口项目的入口为DispatcherSerlvet的init()方法中,在Servlet 的 init 方法初始化了IOC容器和...
用Compass提供的Spring2 Schema 来配置Compass与Hibernate,Spring的结合。 SchemaBase的配置是Spring 2.0的新特征,相比原来的配置代码要少一些。 3.编写搜索结果显示页,将Hits,Command,Page三个变量显示出来。 ...
1.Spring多种开发方式:XML方式、注解方式、schema方式、p命名空间方式等; 2.Spring核心基石:控制反转IOC/ID ; 3.Spring切面编程:AOP; 4.使用Spring开发JAVA项目、Web项目; 5.使用Spring整合MyBatis 6.Spring...
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context=...
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc=...
你也可以把它作为Spring Boot技术的学习项目,Spring Boot Blog也足够符合要求,且代码和功能完备 tips 数据库文件目录为docs/mysql/schema.sql 部署后你可以根据自己需求修改版权文案、logo图片、备案记录等信息 ...
<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:mvc=...