<?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:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/cake?useUnicode=true&characterEncoding=utf-8"></property> <property name="username" value="root"></property> <property name="password" value="99860315"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource"></ref> </property> <property name="configLocation"> <value>classpath:hibernate.cfg.xml</value> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> </props> </property> </bean> <!-- 切面(处理事务) --> <bean id="tm" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="ShopDAO" class="com.xasxt.cake.po.ShopDAO"> <property name="sessionFactory"> <ref bean="sessionFactory"></ref> </property> </bean> <bean id="CakeDAO" class="com.xasxt.cake.po.CakeDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="OrderformDAO" class="com.xasxt.cake.po.OrderformDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="OrderitemDAO" class="com.xasxt.cake.po.OrderitemDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="CustomerDAO" class="com.xasxt.cake.po.CustomerDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="AddressDAO" class="com.xasxt.cake.po.AddressDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <!-- 原始业务类 Target --> <bean id="shopBizTarget" class="com.xasxt.cake.biz.impl.ShopBiz"> <property name="shopDAO" ref="ShopDAO"> </property> </bean> <bean id="cakeBizTarget" class="com.xasxt.cake.biz.impl.CakeBiz"> <property name="cakeDAO" ref="CakeDAO"></property> </bean> <!-- 抽象Bean (模板) --> <bean id="BizTemplate" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager" ref="tm"></property> <!-- 谁来代理 --> <property name="proxyTargetClass" value="true"></property> <!-- 代理方式true:cglib, false:动态代理 --> <property name="transactionAttributes"> <props> <!-- 事务的传播行为 --> <prop key="get*">PROPAGATION_REQUIRED, readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED, readOnly</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="shopBiz" parent="BizTemplate"> <property name="target" ref="shopBizTarget"></property> <!-- 代理谁? --> </bean> <bean id="cakeBiz2" parent="BizTemplate"> <property name="target" ref="cakeBizTarget"></property> <!-- 代理谁? --> </bean> <bean id="customerBizTarget" class="com.xasxt.cake.biz.impl.CustomerBiz"> <property name="customerDAO" ref="CustomerDAO"></property> </bean> <bean id="customerBiz" parent="BizTemplate"> <property name="target" ref="customerBizTarget"></property> </bean> <!-- action --> <bean name="/shop" class="com.xasxt.cake.web.struts.action.ShopAction"> <property name="shopBiz" ref="shopBiz"></property> </bean> <bean name="/cake" class="com.xasxt.cake.web.struts.action.CakeAction"> <property name="cakeBiz" ref="cakeBiz"></property> </bean> <bean name="/cart" class="com.xasxt.cake.web.struts.action.CartAction"> <property name="cakeBiz" ref="cakeBiz"></property> </bean> <bean name="/login" class="com.xasxt.cake.web.struts.action.LoginAction"> <property name="customerBiz" ref="customerBiz"></property> </bean> <!-- 安全切面 --> <bean id="safe" class="com.xasxt.cake.aspect.SafeAsepct"/> <!-- 配置代理 --> <bean id = "cakeBiz" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target" ref="cakeBiz2"></property> <property name="interceptorNames" value="safe"></property> </bean> </beans>
详细解决方案
spring aop 剖面 配置实例
热度:497 发布时间:2012-08-29 08:40:14.0
相关解决方案
- Spring MVC开发模式,怎么取得新增的id
- spring 表单对象绑定有关问题 String与Long的转换
- spring+quartz定时器有关问题
- spring @Scope("prototype")注解更新有关问题,寻求帮助
- Spring MVC是不是可以完全取代Struts
- spring+quartz的错误,不能正常启动
- spring mvc +ibatis+db2连接数据库的配置如何写啊小弟我链接不下
- spring MVC cvc-complex-type.2.4.c解决方案
- Spring + Mybatis 组合报错
- Spring 中 packagesToScan有关问题
- Spring MVC中点击旋钮没反应
- spring aop这个跳转异常是咋回事
- spring security3的一个小疑点。加急
- spring 事务 aop transactionManager,该怎么解决
- Spring 事务管理,该怎么处理
- 关于 Spring 声明式事务管理!解决办法
- Struts2+Spring+JPA+FREEMARKER 登录程序异常
- 关于 Spring 宣言式事务管理!
- 求SSM分页 struts +spring+mybatis 给小弟我发个学习学习吧 多谢大神们
- spring placeholderConfig的有关问题
- spring 事宜 aop transactionManager
- Spring 事务管理,该怎么解决
- struts2 + spring 整合有关问题
- struts+spring+mybatis出现错误(java.lang.ClassNotFoundException: Entity)为提示位置
- 求解 struts+spring+mybatis sqlsession为空 debug发现没有执行set方法 检查配置好像没有关问题
- 新手求教。spring+axis2集成的有关问题。The endpoint reference (EPR) for the Operation not found
- Spring 和 hibernate如何配置事物
- hibernate与此同时使用多数据源?spring+hibernate
- Spring 动态代理,该怎么解决
- cfx Spring 跟 Spring MVC一起用报错