Spring配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	   xmlns="http://www.springframework.org/schema/beans"
	   xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                           http://www.springframework.org/schema/tx 
                           http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context-3.0.xsd">

  <context:annotation-config />
  
  <context:component-scan base-package="com.test.action"/>
  <context:component-scan base-package="com.test.biz"/>
  <context:component-scan base-package="com.test.dao"/>
  
  <bean id="dataSourceLocal" name="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
	<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
	<property name="url" value="jdbc:oracle:thin:@10.202.6.21:1521:oradev"/>
	<property name="username" value="test"/>
	<property name="password" value="test"/>
	<property name="maxActive" value="30"/>
	<property name="maxIdle" value="20"/>
	<property name="maxWait" value="10000"/>
  </bean>
  
  <bean id="localSessionFactory" name="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSourceLocal"/>
    <property name="mappingLocations"> 
	    <value>classpath:com/test/resource/hibernate/*.xml</value> 
	</property>
    <property name="hibernateProperties">
      <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
        <prop key="hibernate.jdbc.batch_size">50</prop>
      </props>
    </property>
  </bean>
  
  <bean id="localTransactionManager" name="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"/>
  </bean>
  
  <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
    <property name="transactionManager" ref="transactionManager"/>
    <property name="transactionAttributes">
      <props>
        <prop key="add*">PROPAGATION_REQUIRED,-Exception</prop>
        <prop key="save*">PROPAGATION_REQUIRED,-Exception</prop>
        <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
        <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
        <prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop>
        <prop key="remove*">PROPAGATION_REQUIRED,-Exception</prop>
        <prop key="tran*">PROPAGATION_REQUIRED,-Exception</prop>
        <prop key="commit*">PROPAGATION_REQUIRED,-Exception</prop>
        <prop key="create*">PROPAGATION_REQUIRED,-Exception</prop>
      </props>
    </property>
  </bean>
  
	<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
		<property name="beanNames">
			<list>
				<value>*Biz</value>
			</list>
		</property>
		<property name="interceptorNames">
			<list>
				<value>transactionInterceptor</value>
			</list>
		</property>
	</bean>
  
</beans>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值