<?xml version="1.0" encoding="UTF-8"?>
<beans default-lazy-init="false"
       xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
       xmlns:aop="http://www.springframework.org/schema/aop">

    <!--业务Beans, 使用注解方式配置-->
    <context:component-scan base-package="com.yihu.hos">
    </context:component-scan>

    <!--Hibernate 数据库配置-->
    <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>

        <property name="url" value="jdbc:mysql://172.19.103.71:3306/esb?useUnicode=true&amp;characterEncoding=UTF-8"/>
        <property name="username" value="hos"/>
        <property name="password" value="hos"/>
        <property name="initialSize" value="1"/>
        <property name="maxTotal" value="100"/>
        <property name="maxIdle" value="50"/>
        <property name="minIdle" value="20"/>
        <property name="validationQuery" value="SELECT 1"/>
        <property name="testOnBorrow" value="true"/>
        <property name="removeAbandonedTimeout" value="55"/>
    </bean>

    <!--Hibernate 会话管理器配置-->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="packagesToScan">
            <list>
                <!-- 可以加多个包 -->
                <value>com.yihu.hos.rest.models</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
                hibernate.show_sql=false
                hibernate.format_sql=true
            </value>
        </property>
        <property name="mappingLocations">
            <list>
                <!-- <value>classpath:hbm/*.hbm.xml</value>-->
                <value>classpath:hibernate/*.hbm.xml</value>
            </list>
        </property>
    </bean>
    <!-- 将多个配置文件读取到容器中，交给Spring管理 -->
    <!--Hibernate 事务配置-->
    <bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
    <tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>

    <!--文件上传支持-->
    <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>

    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
        <property name="cookieMaxAge" value="604800"/>
        <property name="defaultLocale" value="zh_CN"/>
        <property name="cookieName" value="Language"></property>
    </bean>

    <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"/>
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource"/>
    </bean>
    <!--Hibernate模版配置 -->
    <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    <!--<bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" scope="singleton">-->
        <!--<property name="dataSource" ref="dataSource"/>-->
        <!--<property name="configLocation" value="classpath:/config/quartz.properties" />-->
        <!--<property name="autoStartup" value="true"/>-->
    <!--</bean>-->
</beans>