SSH整合配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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.0.xsd 
http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd">



    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location">
            <value>classpath:jdbc.properties</value>
        </property>
    </bean>

    <!-- 配置数据源 -->
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <property name="driverClass" value="com.mysql.jdbc.Driver" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="user" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />
        <property name="autoCommitOnClose" value="false" />
        <property name="checkoutTimeout" value="${cpool.checkoutTimeout}" />
        <property name="initialPoolSize" value="${cpool.minPoolSize}" />
        <property name="minPoolSize" value="${cpool.minPoolSize}" />
        <property name="maxPoolSize" value="${cpool.maxPoolSize}" />
        <property name="maxIdleTime" value="${cpool.maxIdleTime}" />
        <property name="acquireIncrement" value="${cpool.acquireIncrement}" />
        <property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}" />
        <property name="idleConnectionTestPeriod" value="180" />
        <property name="acquireRetryAttempts" value="30" />
    </bean>


    <!--配置SessionFactory -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.connection.useUnicode">true</prop>
                <prop key="hibernate.connection.characterEncoding">UTF-8</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.cache.use_query_cache">true</prop>
                <prop key="hibernate.jdbc.fetch_size">50</prop>
                <prop key="hibernate.jdbc.batch_size">10</prop>
                <prop key="use_streams_for_binary">true</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider
                </prop>
                <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory
                </prop>
                <prop key="hibernate.generate_statistics">true</prop>
                <prop key="hibernate.connection.release_mode">auto</prop>
            </props>
        </property>
        <property name="packagesToScan">
            <list>
                <value>net.totosea.*</value>
            </list>
        </property>
    </bean>

    <!-- 事务管理 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>


    <bean id="transactionInterceptor" abstract="false" lazy-init="true"
        class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <property name="transactionManager">
            <ref local="transactionManager" />
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="save*">PROPAGATION_REQUIRED</prop>
                <prop key="insert*">PROPAGATION_REQUIRED</prop>
                <prop key="del*">PROPAGATION_REQUIRED</prop>
                <prop key="add*">PROPAGATION_REQUIRED</prop>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
                <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="search*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="remove*">PROPAGATION_REQUIRED</prop>
                <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="list*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="count*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
            </props>
        </property>
    </bean>

    <!-- hibernateTemplate -->
    <bean id="hibernateTemplate" name="hibernateTemplate"
        class="org.springframework.orm.hibernate3.HibernateTemplate">
        <property name="sessionFactory">
            <ref bean="sessionFactory" />
        </property>
    </bean>

    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource" />
    </bean>

    <bean
        class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <property name="beanNames">
            <list>
                <value>hibernateService</value>
                <value>service</value>
            </list>
        </property>
        <property name="interceptorNames">
            <list>
                <value>transactionInterceptor</value>
            </list>
        </property>
    </bean>

    <bean id="hibernateDao" name="hibernateDao" class="net.totosea.dao.HibernateDaoImpl">
        <property name="hibernateTemplate" ref="hibernateTemplate"></property>
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>


    <bean id="hibernateService" name="hibernateService"
        class="net.totosea.service.HibernateServiceImpl" abstract="false"
        lazy-init="default" autowire="default">
        <property name="hibernateDao" ref="hibernateDao"></property>
    </bean>

    <bean name="dao" id="dao" class="net.totosea.dao.DAOImpl">
        <property name="hibernateTemplate" ref="hibernateTemplate"></property>
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>

    <bean id="service" name="service" class="net.totosea.service.ServiceImpl"
        abstract="false" lazy-init="default" autowire="default">
        <property name="dao" ref="dao"></property>
    </bean>



</beans>
jdbc.url=jdbc:mysql://localhost:3306/totosea?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=root
cpool.checkoutTimeout=10000
cpool.minPoolSize=1
cpool.maxPoolSize=100
cpool.maxIdleTime=10000
cpool.acquireIncrement=5
cpool.maxIdleTimeExcessConnections=1800
broker.tcp.local.name=localhost

broker.tcp.local.url=tcp\://localhost\:61616?trace\=true&keepAlive\=true

broker.tcp.local.queue=TOTOSEAQUEUE.>

broker.tcp.local.topic=TOTOSEATOPIC.>

broker.tcp.local.topic=TOTOSEATOPIC2.>
posted @ 2012-04-11 17:08  园林鸟  阅读(1500)  评论(0编辑  收藏  举报