Spring beans.xml(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:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
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.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-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/context http://www.springframework.org/schema/context/spring-context-3.0.xsd ">
<context:component-scan base-package="util.base"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="net.sourceforge.jtds.jdbc.Driver"></property>
<!-- <property name="jdbcUrl" value="jdbc:jtds:sqlserver://192.168.0.1:1124/saa;charset=gbk;SelectMethod=CURSOR"></property> -->
<property name="jdbcUrl" value="jdbc:jtds:sqlserver://192.168.0.1:1124/aa;charset=gbk;SelectMethod=CURSOR;useLOBs=false"></property>
<property name="user" value="sa"></property>
<property name="password" value="111111"></property>
<!-- 连接池配置 -->
<property name="minPoolSize"><value>2</value></property>
  <property name="maxPoolSize"><value>100</value></property>
<property name="maxIdleTime"><value>1800</value></property>
  <property name="acquireIncrement"><value>2</value></property>
  <property name="maxStatements"><value>0</value></property>
  <property name="initialPoolSize"><value>2</value></property>
  <property name="idleConnectionTestPeriod"><value>1800</value></property>
  <property name="acquireRetryAttempts"><value>30</value></property>
  <property name="breakAfterAcquireFailure"><value>true</value></property>
  <property name="testConnectionOnCheckin"><value>true</value></property>
  <property name="testConnectionOnCheckout"><value>true</value></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
             <props>
              <prop key="hibernate.dialect">org.hibernate.dialect.SQLServer2008Dialect</prop>
<!-- 解决no session found -->
<!-- <prop key="hibernate.current_session_context_class">
thread
</prop> -->
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
                <!-- hibernate二级缓存的配置 -->
                <!--  
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
                -->
             </props>
          </property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:pt/pojo</value>
<value>classpath:que/pojo</value>
</list>
</property>
</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="exists" read-only="true" />  
          <tx:method name="save*" propagation="REQUIRED" />    
        <tx:method name="add*" propagation="REQUIRED" />    
          <tx:method name="create*" propagation="REQUIRED" />    
          <tx:method name="insert*" propagation="REQUIRED" />    
          <tx:method name="update*" propagation="REQUIRED" />    
          <tx:method name="merge*" propagation="REQUIRED" />    
          <tx:method name="del*" propagation="REQUIRED" />    
          <tx:method name="remove*" propagation="REQUIRED" />    
          <tx:method name="put*" propagation="REQUIRED" />    
          <tx:method name="use*" propagation="REQUIRED"/>    
          <tx:method name="get*" propagation="REQUIRED" />    
          <tx:method name="count*" propagation="REQUIRED" read-only="true" />    
          <tx:method name="find*" propagation="REQUIRED" read-only="true" />    
          <tx:method name="list*" propagation="REQUIRED" read-only="true" />   
          <tx:method name="*" propagation="REQUIRED" />              
        </tx:attributes> 
    </tx:advice>
<aop:config>
<aop:advisor advice-ref="txAdvice" pointcut="execution(* *..*Service.*(..))"/>
</aop:config>
    
<import resource="classes/conf/app-dao.xml"/>
<import resource="classes/conf/app-service.xml"/>
<import resource="classes/conf/app-action.xml"/>
<import resource="classes/conf/app-dwr.xml"/>
<import resource="classes/conf/xfire-servlet.xml"/>

</beans>


阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页