spring - ibatis 配置文件

  1. applicationContext.xml
    <?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"
        default-autowire="byName" default-lazy-init="true">
    
        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath*:jdbc.properties</value>
                </list>
            </property>
        </bean>
      
    	<!--===========loggingProxyCreator==============-->
    	<bean id="loggingProxyCreator"
    		class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        	<description></description>
        	<property name="beanNames">
          		<description></description>
          		<value>*Logic,*Action,*Service,*Dao</value>
        	</property>
        	<property name="proxyTargetClass">
    	    	<value>true</value>
        	</property>
        	<property name="interceptorNames">
          		<list>
            		<value>loggingInterceptor</value>
          		</list>
        	</property>
      	</bean>
      	
      <bean id="loggingInterceptor"
          class="org.springframework.aop.interceptor.CustomizableTraceInterceptor">
        <description></description>
        <property name="useDynamicLogger">
          <value>true</value>
        </property>
        <property name="enterMessage">
          <description>方法开始调用时</description>
          <value>方法开始[类名]=$[targetClassName]、[方法名]=$[methodName]、[参数值]=$[arguments]</value>
        </property>
        <property name="exitMessage">
          <description>方法正常调用时</description>
          <value>方法完成[类名]=$[targetClassName]、[方法名]=$[methodName]、[参数值]=$[arguments]、[返回值]=$[returnValue]</value>
        </property>
        <property name="exceptionMessage">
          <description>异常发生时</description>
          <value>异常发生[类名]=$[targetClassName]、[方法名]=$[methodName]、[参数值]=$[arguments]</value>
        </property>
      </bean>
    
    </beans>
    
     2.applicationContext-dataSource.xml
    <?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"
        default-autowire="byName" default-lazy-init="true">
    
        <!--for JDBC dataSource -->
        <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="${jdbc.driverClassName}" />
            <property name="url" value="${jdbc.url}" />
            <property name="username" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />
        </bean>
    
        <!--for JNDI dataSource
        <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName">
                <value>jndi/kpi</value>
            </property>
        </bean>
        -->
    
        <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
            <property name="configLocation" value="classpath:sql-map-config.xml" />
            <property name="dataSource" ref="dataSource" />
        </bean>
    
        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource" />
        </bean>
    
          <bean id="businessBean"
    
            class="org.springframework.aop.framework.ProxyFactoryBean">
    
             <property name="singleton">
    
                 <value>true</value>
    
             </property>
    
             <property name="proxyInterfaces">
    
                 <value>com.cn.tx.jjm.services.ITransationService</value>
    
             </property>
    
             <property name="interceptorNames">
    
                 <list>
    
                    <value>transactionInterceptor</value>
    
                    <!--value>com.cn.ffml.ytzk.PRD03U04.action.PRD03U04Action</value-->
    
                 </list>
    
             </property>
    
             <property name="proxyTargetClass"><value>true</value></property>
    
          </bean>
    
         
    
          <bean id="transactionInterceptor"
    
            class="org.springframework.transaction.interceptor.TransactionInterceptor">
    
             <property name="transactionManager">
    
                 <ref local="transactionManager" />
    
             </property>
    
             <property name="transactionAttributes">
    
                 <props>
    
                    <prop key="*">PROPAGATION_REQUIRED,-Exception</prop>
    
                 </props>
    
             </property>
    
          </bean> 
    
    </beans>
    
     

你可能感兴趣的:(spring,ibatis)