Maven 多模块开发(六)-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/tx
            http://www.springframework.org/schema/tx/spring-tx-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
                ">

    <!-- ============================================== -->

    <!-- =========== Spring 公用配置 =================== -->

    <!-- ============================================== -->

    <bean id="placeholderConfig"

        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

        <property name="location">

            <value>classpath:hibernate.properties</value>

        </property>

    </bean>

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"

        destroy-method="close">

        <!-- 安全的路径jdbc:mysql://127.0.0.1:3306/va66?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;mysqlEncoding=utf8 -->

        <property name="jdbcUrl" value="${hibernate.connection.url}" />

        <property name="driverClass" value="${hibernate.connection.driver_class}" />

        <property name="user" value="${hibernate.connection.username}" />

        <property name="password" value="${hibernate.connection.password}" />

        <property name="acquireIncrement" value="${c3p0.acquireIncrement}" />

        <property name="initialPoolSize" value="${c3p0.initialPoolSize}" />

        <property name="minPoolSize" value="${c3p0.minPoolSize}" />

        <property name="maxPoolSize" value="${c3p0.maxPoolSize}" />

        <property name="maxStatements" value="${c3p0.maxStatements}" />

        <property name="numHelperThreads" value="${c3p0.numHelperThreads}" />

        <property name="maxIdleTime" value="${c3p0.maxIdleTime}" />

    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
        p:dataSource-ref="dataSource" p:configLocation="classpath:hibernate.cfg.xml">
        <!-- <property name="mappingResources"> <list> <value>com/wrs/model/Customer.hbm.xml</value>
            <value>com/wrs/model/Slide.hbm.xml</value> <value>com/wrs/model/SecondLevelInfo.hbm.xml</value>
            <value>com/wrs/model/InfoDetail.hbm.xml</value> <value>com/wrs/model/IndexOneCategory.hbm.xml</value>
            <value>com/wrs/model/IndexTwoCategory.hbm.xml</value> <value>com/wrs/model/FirstLevelInfo.hbm.xml</value>
            <value>com/wrs/model/Manager.hbm.xml</value> </list> </property> -->
        <property name="hibernateProperties">

            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>

                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.autoReconnect">true</prop>
                <prop key="hibernate.generate_statistics">true</prop>
                              <prop
                    key="hibernate.use_sql_comments">false</prop>
                     <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
               
                 <prop key="hibernate.connection.release_mode">auto</prop>
   
                    <prop key="hibernate.hbm2ddl.auto">update</prop>

                <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
                 <prop key="current_session_context_class">thread</prop>
            </props>

        </property>

    </bean>



    <bean id="transactionManager"

        class="org.springframework.orm.hibernate4.HibernateTransactionManager"

        p:sessionFactory-ref="sessionFactory" />
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="select*" read-only="true" propagation="REQUIRED" />
            <tx:method name="get*" read-only="true" propagation="REQUIRED" />
            <tx:method name="load*" read-only="true" propagation="REQUIRED" />
            <tx:method name="find*" read-only="true" propagation="REQUIRED" />
            <tx:method name="query*" read-only="true" propagation="REQUIRED" />
            <tx:method name="read*" read-only="true" propagation="REQUIRED" />
            <tx:method name="sync*" propagation="REQUIRED" />
            <tx:method name="insert*" propagation="REQUIRED" />
            <tx:method name="update*" propagation="REQUIRED" />
            <tx:method name="edit*" propagation="REQUIRED" />
            <tx:method name="*" propagation="REQUIRED" rollback-for="Exception" />
        </tx:attributes>
    </tx:advice>
    <aop:config>
        <aop:pointcut id="pointcut"
            expression="execution(* com.wrs.service.impl.*.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
    </aop:config>

    <!-- Dao -->
    <bean id="baseDao" class="com.wrs.dao.impl.BaseDaoImpl">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>

    <!-- Service -->
    <bean id="customerService" class="com.wrs.service.impl.CustomerServiceImpl">
        <property name="baseDao">
            <ref bean="baseDao" />
        </property>
    </bean>
</beans>

你可能感兴趣的:(Maven 多模块开发(六)-applicationContext.xml)