zoukankan      html  css  js  c++  java
  • 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:context="http://www.springframework.org/schema/context"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
            
        <!-- 加载jdbc.property,hibenrate.properties -->        
        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath:setting/jdbc.properties</value>
                    <value>classpath:setting/hibernate.properties</value>
                </list>
            </property>
        </bean>
        
        <!-- dataSource -->
        <bean id="dataSource"
            class="org.apache.commons.dbcp.BasicDataSource">
            <property name="driverClassName"
                value="${jdbc.driverClassName}">
            </property>
            <property name="url"
                value="${jdbc.url}">
            </property>
            <property name="username" value="${jdbc.username}"></property>
            <property name="password" value="${jdbc.password}"></property>
            <property name="maxIdle" value="3"></property>
            <property name="maxActive" value="5"></property>
        </bean>
    
            
        <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
            <property name="dataSource" ref="dataSource"></property>
            <property name="packagesToScan">
                <list>
                    <value>com.soft.security.domain</value>
                    <value>com.soft.work.domain</value>
                </list>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                                
                    <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
                    <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}</prop>
                    <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
                    <prop key="hibernate.net.sf.ehcache.configurationResourceName">${hibernate.net.sf.ehcache.configurationResourceName}</prop>
                    
                    <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
                    <prop key="hibernate.jdbc.fetch_size">${hibernate.jdbc.fetch_size}</prop>
                    <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
                    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                    <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                    <prop key="hibernate.use_sql_comments">${hibernate.use_sql_comments}</prop>
                </props>
            </property>
        </bean>    
        
        <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"></property>
        </bean>
        
        <tx:advice id="txAdvice">
            <tx:attributes>
                <tx:method name="add*" propagation="REQUIRED"/>
                <tx:method name="save*" propagation="REQUIRED"/>
                <tx:method name="delete*" propagation="REQUIRED"/>
                <tx:method name="update*" propagation="REQUIRED"/>
                <tx:method name="do*" propagation="REQUIRED"/>
                <tx:method name="*" propagation="REQUIRED" read-only="true"/>
            </tx:attributes>
        </tx:advice>
        
        <aop:config proxy-target-class="true">
            <aop:pointcut expression="execution(* com.soft.security.dao.*.*(..)) || execution(* com.soft.core.dao.*.*(..)) || execution(* com.soft.process.dao.*.*(..))" id="securityMethods"/>
            <aop:advisor advice-ref="txAdvice" pointcut-ref="securityMethods"/>
        </aop:config>
         
        <context:component-scan base-package="com.soft"></context:component-scan>
        <context:annotation-config></context:annotation-config>
        <tx:annotation-driven/>
        
    </beans>
    如果有使用请标明来源:http://www.cnblogs.com/duwenlei/
  • 相关阅读:
    TopCoder<SRM>上的一道1100分的题目解析附代码
    《算法导论》思考题15-2 整齐打印
    《算法导论》思考题15-1 双调欧几里得旅行商问题(动态规划)
    <ReversingEngineering>关于windows32位系统下的dll注入技术经验汇
    实现一个EventEmitter类,这个类包含以下方法: on/ once/fire/off
    [Jquery 插件]活动倒计时,可同步服务器时间,倒计时格式随意设置
    阻止a标签跳转四种方法 兼容各大浏览器(包括IE)
    git常用操作 配置用户信息、拉取项目、提交代码、分支操作、版本回退...
    nrm npm源管理利器
    Element UI 框架搭建
  • 原文地址:https://www.cnblogs.com/duwenlei/p/3872737.html
Copyright © 2011-2022 走看看