zoukankan      html  css  js  c++  java
  • springAOP配置文件

      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <beans
      3     xmlns="http://www.springframework.org/schema/beans"
      4     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      5     xmlns:aop="http://www.springframework.org/schema/aop"
      6     xmlns:tx="http://www.springframework.org/schema/tx"
      7     xmlns:p="http://www.springframework.org/schema/p"
      8     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      9         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
     10            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> 
     11     <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
     12         <property name="driverClassName">
     13             <value>com.mysql.jdbc.Driver</value>
     14         </property>
     15         <property name="url">
     16             <value>jdbc:mysql://localhost:3306/ssh2</value>
     17         </property>
     18         <property name="username">
     19             <value>root</value>
     20         </property>
     21         <property name="password">
     22             <value>123456</value>
     23         </property>
     24     </bean>
     25     <!-- 配置sessionFactory -->
     26     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
     27         <property name="dataSource" ref="dataSource"></property>
     28         <property name="hibernateProperties">
     29             <props>
     30                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
     31                 <prop key="hibernate.show_sql">true</prop>
     32             </props>
     33         </property>
     34         <property name="mappingResources">
     35             <list>
     36                 <value>com/zhanghaobo/bean/User.hbm.xml</value>
     37             </list>
     38         </property>
     39     </bean>
     40     <!-- 配置事务管理器 -->
     41     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
     42         <property name="sessionFactory" ref="sessionFactory"></property>
     43     </bean>
     44     <!-- 哪些类哪些方法使用事务 -->
     45     <aop:config>
     46         <!-- 定义在哪些方法上开启事务-->
     47         <aop:pointcut expression="execution(* com.zhanghaobo.service.impl.*.*(..))" id="allManagerMethod"/>
     48         <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
     49         <aop:aspect id="authorAspect" ref="authorityInterceptor">
     50             <aop:before method="checkAuthor" pointcut-ref="allManagerMethod"/>
     51         </aop:aspect>
     52     </aop:config>
     53     <!-- 事务的传播特性  -->
     54     <tx:advice id="txAdvice" transaction-manager="transactionManager">
     55         <tx:attributes>
     56             <tx:method name="find*" propagation="REQUIRED" read-only="true" />
     57             <tx:method name="*" propagation="REQUIRED"/>
     58         </tx:attributes>
     59     </tx:advice>
     60     <bean id="authorityInterceptor" class="com.zhanghaobo.interceptor.AuthorityInterceptor">
     61         <property name="user">
     62             <value>aaa</value>
     63         </property>
     64     </bean>
     78     <bean id="userService" class="org.springframework.aop.framework.ProxyFactoryBean" >
     79         <property name="target" ref="userServiceTarget"></property>
     80         <property name="proxyInterfaces">
     81             <value>com.zhanghaobo.service.UserService</value>
     82         </property>
     83 
     84         <property name="interceptorNames">
     85             <value>authorityInterceptor</value>
     86         </property>
     87     </bean>
     88     <bean id="userDao" class="com.zhanghaobo.dao.impl.UserDAOImpl" scope="singleton">
     89         <property name="sessionFactory" ref="sessionFactory"></property>
     90     </bean>
     91     <bean id="userServiceTarget" class="com.zhanghaobo.service.impl.UserServiceImpl" scope="singleton">
     92         <property name="userdao" ref="userDao"></property>
     93     </bean>
     94     <bean id="saveUserAction" class="com.zhanghaobo.action.user.SaveUserAction" scope="prototype">
     95         <property name="userService" ref="userService"></property>
     96     </bean>
     97     <bean id="listUserAction" class="com.zhanghaobo.action.user.listUser" >
     98         <property name="userService" ref="userService"></property>
     99     </bean>
    100 </beans>
  • 相关阅读:
    商户编号前三位代码对应的收单机构大全
    使用邮件模板(freemarker.jar)发送邮件
    Struts2自定义拦截器
    如何在jsp页面显示存储在数据库的图片
    正则表达式 大于0的数字(包含小数)
    Linux的关机命令
    maven的下载和安装
    web.py的安装
    安装第三方插件BeautifulSoup
    myeclipse离线安装pydev插件
  • 原文地址:https://www.cnblogs.com/oldcownotGiveup/p/5372066.html
Copyright © 2011-2022 走看看