一些配置

<?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:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:util="http://www.springframework.org/schema/util"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-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/util
    http://www.springframework.org/schema/util/spring-util-3.1.xsd">

    <context:annotation-config />
    <context:component-scan base-package="cn.com.sparknet.*">
        <!-- 过滤掉@Controller的类 -->
        <context:exclude-filter type="annotation"
            expression="org.springframework.stereotype.Controller" />
    </context:component-scan>
     
<!-- <bean id="propertyConfigurer"
        class="cn.com.sparknet.common.util.property.ReadProperties">
        <property name="ignoreResourceNotFound" value="true" />  
        <property name="locations">
            <list>
                <value>/WEB-INF/basicConfig.properties</value>
                <value>/WEB-INF/dispatchConfig.properties</value>
            </list>
        </property>
    </bean> -->    
    <!-- 配置连接池-->
    <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
        <property name="alias" value="blspLicense"></property><!--别名 -->
        <property name="driver" value="oracle.jdbc.driver.OracleDriver" /><!--驱动 -->
        <property name="driverUrl" value="jdbc:oracle:thin:@192.168.1.24:1521:ZJQLDATA" /><!--地址 -->
        <property name="delegateProperties"
            value="user=ZZLDJGNMG,password=ZZLDJGNMG" /><!--用户密码 -->
        <property name="user" value="" /><!--无需填写但必须存在 -->
        <property name="password" value="" /><!--无需填写但必须存在 -->
        <property name="minimumConnectionCount" value="2" /><!--最小连接数 
            默认2 -->
        <property name="maximumConnectionCount" value="1000" /><!--最大连接数 
            默认5 -->
        <property name="maximumActiveTime" value="172800000" /><!--检测到某个线程的活动时间大于这个数值.它将会杀掉这个线程(毫秒) -->
        <property name="houseKeepingSleepTime" value="600000" /><!--侦察(自动)到空闲的连接就马上回收,超时的销毁(毫秒) 
            默认30秒 -->
        <property name="prototypeCount" value="2" /><!--最少保持的空闲连接数 默认2 -->
        <property name="simultaneousBuildThrottle" value="10" /><!--没有空闲连接可以分配而在队列中等候的最大请求数,超过这个请求数的用户连接就不会被接受 -->
        <property name="maximumConnectionLifetime" value="180000000" /><!--连接最大生命时间 
            默认4小时 -->
        <property name="testBeforeUse" value="true" /><!-- 执行SQL之前测试连接 -->
        <property name="testAfterUse" value="true" /><!-- 执行SQL之后测试连接 -->
        
        <property name="statisticsLogLevel" value="DEBUG" />
        <property name="trace" value="true" /><!-- 如果为true,那么每个被执行的SQL语句将会在执行期被log记录(DEBUG LEVEL). -->
        <property name="verbose" value="true" />
        <property name="houseKeepingTestSql" value="SELECT CURRENT_DATE FROM DUAL" /><!--用于保持连接的测试语句 -->
    </bean>

    <!-- 采用weblogic-jndi形式链接数据库 -->
    <!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> 
        <property name="jndiName"> <value>xGovFlowJNDI</value> </property> </bean> -->
  <!--注入JDBCjavabean -->
    <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <property name="dataSource" ref="dataSource" />
    </bean>
    <!-- 配置JDBC事务管理器 -->
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
    </bean>
    <!-- 使用拦截器 -->
    <bean id="transactionInterceptor"
        class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <property name="transactionManager">
            <ref bean="transactionManager" />
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="remove*">PROPAGATION_REQUIRED</prop>
                <prop key="update*">PROPAGATION_REQUIRED</prop>
                <prop key="save*">PROPAGATION_REQUIRED</prop>
        <prop key="insert*">PROPAGATION_REQUIRED</prop>
                <prop key="merge*">PROPAGATION_REQUIRED</prop>
                <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                <prop key="get*">PROPAGATION_SUPPORTS,readOnly</prop>
            </props>
        </property>
    </bean>
    <!-- 自动代理 -->
    <bean id="autoproxy"
        class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <!-- 可以是Service或DAO层(最好是针对业务层*Service) -->
        <property name="beanNames">
            <list>
                <value>*Service</value>
                <value>*Interface</value>
            </list>
        </property>
        <property name="interceptorNames">
            <list>
                <value>transactionInterceptor</value>
                <value>transactionInterceptor</value>
            </list>
        </property>
    </bean>

    <!-- 统一处理json -->
    <bean id="mappingJacksonHttpMessageConverter"
        class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
        <property name="supportedMediaTypes">
            <list>
                <value>application/json;charset=UTF-8</value>
                <value>text/html;charset=UTF-8</value>
            </list>
        </property>
    </bean>
    
    

</beans>

 

posted @ 2018-04-17 09:00  花满园  阅读(129)  评论(0)    收藏  举报