data-source.xml 4.48 KB
<?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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!-- DBCP连接池 -->
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.driver}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <property name="defaultAutoCommit" value="false" />
        <property name="filters" value="config" />
        <property name="connectionProperties" value="config.decrypt=true" />

        <!--<property name="connectionInitSqls" value="set names utf8mb4;"/>-->
    </bean>

    <!--  TransactionManager定义 -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <!-- 使用annotation定义事务 -->
    <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

    <!-- MyBatis配置 -->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <!-- 自动扫描模型对象目录, 省掉Configuration.xml里的手工配置, 改为明确的控制
        <property name="typeAliasesPackage" value="com.xniu.xxx.contract" /> -->
        <!-- 指定Mapper文件位置 -->
        <property name="mapperLocations" value="classpath:/mapper/*/*.xml"/>
        <property name="configLocation"  value="classpath:/mybatis_setting.xml" />
        <property name="configurationProperties">
            <props>
                <prop key="mapUnderscoreToCamelCase">true</prop>
                <prop key="aggressiveLazyLoading">false</prop>
                <prop key="cacheEnabled">true</prop>
                <prop key="useColumnLabel">true</prop>
                <!--<prop key="useGeneratedKeys">true</prop>-->
            </props>
        </property>
    </bean>

    <!-- 扫描basePackage下所有以@MyBatisRepository标识的 接口-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.xiniunet.*.dal" />
        <property name="annotationClass" value="com.xiniunet.framework.annotation.MyBatisRepository"/>
    </bean>

    <bean id="dbPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="order" value="1" />
        <property name="ignoreUnresolvablePlaceholders" value="true" />
        <property name="locations">
            <list>
                <value>classpath*:/jdbc.properties</value>
                <value>classpath*:/setting.properties</value>
            </list>
        </property>
    </bean>

    <bean id="cacheManager" class="com.xiniunet.framework.cache.CacheManagerImpl">
        <constructor-arg value="${aliyun.ocs.host}"/>
        <constructor-arg value="${aliyun.ocs.port}"/>
        <constructor-arg value="${deploy.mode}"/>
        <constructor-arg value="${aliyun.ocs.username}"/>
        <constructor-arg value="${aliyun.ocs.password}"/>
    </bean>
    <!--<bean name="quartzScheduler" lazy-init="false"
          class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>

        <property name="applicationContextSchedulerContextKey"
                  value="applicationContextKey" />
        <property name="autoStartup" value="true" />
        <property name="configLocation" value="classpath*:/quartz.properties"/>
    </bean>-->
    <bean id="cacheAop" class="com.xiniunet.framework.cache.CacheAop">
    </bean>





    <bean name="quartzScheduler" id="scheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="applicationContextSchedulerContextKey"
                  value="applicationContextKey" />
        <property name="autoStartup" value="true" />
        <property name="configLocation" value="classpath:/quartz.properties"/>

    </bean>


</beans>