`
zhykhs
  • 浏览: 60650 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

spring1.1和2.0中aop建议配置

阅读更多

1.spring1.1

 

 

<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
	
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
		<property name="url" value="jdbc:mysql://localhost:3306/eimhe"/>
		<property name="username" value="root" />
		<property name="password" value="ok"/>
	</bean>
	
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<property name="mappingResources">
			<list>
				<value>org/springframework/lesson4/Person.hbm.xml</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLDialect
				</prop>				
			</props>
		</property>
	</bean>
	
	<bean id="dao" class="org.springframework.lesson4.PersonDAO">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	
	<bean id="personProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="transactionManager" ref="transactionManager"/>
		<property name="proxyInterfaces">
			<list>
				<value>org.springframework.lesson4.IPersonDAO</value>
			</list>
		</property>
		<property name="target" ref="dao" />
		<property name="transactionAttributes">
			<props>
				<prop key="getAll*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>
</beans>

 

 

2.spring2.0

 

<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
	http://www.springframework.org/schema/tx
	http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
	
	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
		<property name="url" value="jdbc:mysql://localhost:3306/eimhe"/>
		<property name="username" value="root" />
		<property name="password" value="ok"/>
	</bean>
	
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<property name="mappingResources">
			<list>
				<value>org/springframework/lesson4/Person.hbm.xml</value>
			</list>
		</property>
		<property name="hibernateProperties">
			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLDialect
				</prop>				
			</props>
		</property>
	</bean>
	
	<bean id="dao" class="org.springframework.lesson4.PersonDAO">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	
	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>
	
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="getAllPersons" propagation="REQUIRED"/>
		</tx:attributes>
	</tx:advice>
	
	<aop:config>
		<aop:pointcut id="personPointer" expression="execution(* org.springframework.lesson4.IPersonDAO.*(..))"/>
		<aop:advisor advice-ref="txAdvice" pointcut-ref="personPointer"/>
	</aop:config>
</beans>

 

分享到:
评论

相关推荐

    struts2.1.6+spring2.0+hibernate3.2常用配置包

    spring版本有2.0,2.5的,hibernate版本较多些至3.2,首先选版本就选择最优的,struts2没的选只有2.1.6版的,所以先导入struts2支持,然后是spring选的是2.0,问题就出在struts2中spring的插件上了,没有从MyEclipse...

    Spring 2.0 开发参考手册

    6.4.2. Spring AOP中使用@AspectJ还是XML? 6.5. 混合切面类型 6.6. 代理机制 6.7. 编程方式创建@AspectJ代理 6.8. 在Spring应用中使用AspectJ 6.8.1. 在Spring中使用AspectJ来为domain object进行依赖注入 ...

    SpringBoot中的AOP+自定义注解(源代码)

    1.4 Spring AOP 和 AspectJ AOP 有什么区别? 2. 在 SpringBoot 中使用 Aop 功能 2.0 创建一个SpringBoot项目 2.1 引入 POM 依赖 2.1.1 引入springboot aop依赖 2.1.2 引入fastjson依赖 2.2 .编写配置类SpringConfig...

    Spring-Reference_zh_CN(Spring中文参考手册)

    6.4.2. Spring AOP中使用@AspectJ还是XML? 6.5. 混合切面类型 6.6. 代理机制 6.7. 编程方式创建@AspectJ代理 6.8. 在Spring应用中使用AspectJ 6.8.1. 在Spring中使用AspectJ来为domain object进行依赖注入 6.8.1.1....

    Spring Framewor开发手册

    2. Spring 2.0和 2.5的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 新的bean作用域 2.2.2. 更简单的XML配置 2.2.3. 可扩展的XML编写 2.2.4. Annotation(注解)驱动配置 2.2.5. 在classpath中自动搜索组件 2.3. ...

    spring2.5.chm帮助文档(中文版)

    2. Spring 2.0和 2.5的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 新的bean作用域 2.2.2. 更简单的XML配置 2.2.3. 可扩展的XML编写 2.2.4. Annotation(注解)驱动配置 2.2.5. 在classpath中自动搜索组件...

    spring.net中文手册在线版

    17.6.2.在.NET 2.0中执行回调 17.6.3. .NET 1.1 17.6.4.AdoTemplate方法指南 17.7.异常翻译 17.8.参数管理 17.8.1. IDbParametersBuilder 17.8.2. IDbParameters 17.9. Mapping DBNull values 17.10. Basic data ...

    Spring in Action(第二版 中文高清版).part2

    6.4.3 在Spring 2.0里声明事务 6.4.4 定义注释驱动事务 6.5 小结 第7章 保护Spring 7.1 Spring Security介绍 7.2 验证用户身份 7.2.1 配置Provider Manager 7.2.2 根据数据库验证身份 7.2.3 根据LDAP仓库...

    Spring in Action(第二版 中文高清版).part1

    6.4.3 在Spring 2.0里声明事务 6.4.4 定义注释驱动事务 6.5 小结 第7章 保护Spring 7.1 Spring Security介绍 7.2 验证用户身份 7.2.1 配置Provider Manager 7.2.2 根据数据库验证身份 7.2.3 根据LDAP仓库...

    spring chm文档

    6.4.2. Spring AOP中使用@AspectJ还是XML? 6.5. 混合切面类型 6.6. 代理机制 6.7. 编程方式创建@AspectJ代理 6.8. 在Spring应用中使用AspectJ 6.8.1. 在Spring中使用AspectJ来为domain object进行依赖注入 ...

    Spring API

    6.4.2. Spring AOP中使用@AspectJ还是XML? 6.5. 混合切面类型 6.6. 代理机制 6.6.1. 理解AOP代理 6.7. 以编程方式创建@AspectJ代理 6.8. 在Spring应用中使用AspectJ 6.8.1. 在Spring中使用AspectJ进行domain ...

    Spring in Action(第2版)中文版

    6.4.3在spring2.0里声明事务 6.4.4定义注释驱动事务 6.5小结 第7章保护spring 7.1springsecurity介绍 7.2验证用户身份 7.2.1配置providermanager 7.2.2根据数据库验证身份 7.2.3根据ldap仓库进行身份验证 ...

    (2.0版本)自己写的struts2+hibernate+spring实例

    aop.jar spring-dao.jar spring-hibernate.jar spring-jdbc.jar spring-mock.jar spring-orm.jar spring-remoting.jar spring-support.jar spring-webmvc.jar

    c3p0-0.9.1.2等等

    spring-aop spring-beans spring-context spring-core spring-dao spring-hibernate3 spring-ibatis spring-jdbc spring-jdo spring-jpa-2.0-m2 spring-struts spring-web spring-webmvc sqljdbc struts velocity-...

    spring发展史与优势

    Spring 是分层的 Java SE/EE 应用 full-stack 轻量级开源框架,以 IoC(Inverse Of Control:反转控制)和 AOP(Aspect Oriented Programming:面向切面编程)为内核,提供了展现层 SpringMVC 和持久层 Spring JDBC ...

    spring和hibernate__jar包,详细说明看jar包列表

    org.springframework.aop-3.1.1.RELEASE.jar org.springframework.asm-3.1.1.RELEASE.jar org.springframework.aspects-3.1.1.RELEASE.jar org.springframework.beans-3.1.1.RELEASE.jar org.springframework....

    Spring3+Hibernate4+Struts2 jar包 SSH框架

    spring-aop-3.2.0.RC2.jar spring-aspects-3.2.0.RC2.jar spring-beans-3.2.0.RC2.jar spring-context-3.2.0.RC2.jar spring-context-support-3.2.0.RC2.jar spring-core-3.2.0.RC2.jar spring-expression-3.2.0.RC2...

    spring+struts+hibernate+dwr+jstl做的实例

    aop.jar spring-agent.jar spring-tomcat-weaver.jar asm-commons-2.2.3.jar asm-util-2.2.3.jar aspectjrt.jar aspectjweaver.jar aopalliance.jar cglib-nodep-2.1_3.jar jakarta-oro-...

    《MyEclipse 6 Java 开发中文教程》前10章

    10.5.2.4 用Spring 2.0 的aop和tx声明式配置解决事务提交问题 247 10.5.2.5 用Spring 2.0 的@Transactional标注解决事务提交问题(最佳方案) 251 10.5.2.6 使用 HibernateTemplate 实现分页查询 254 10.6 小结 255 ...

    SSH(Spring Struts Hibernate)所有jar包

    aop-3.2.6.RELEASE.jar spring-beans-3.2.6.RELEASE.jar spring-context-3.2.6.RELEASE.jar spring-context-support-3.2.6.RELEASE.jar spring-core-3.2.6.RELEASE.jar spring-expression-3.2.6.RELEASE.jar spring-...

Global site tag (gtag.js) - Google Analytics