阅读背景:

Spring MVC +Mybatis + Maven 配置之dataSource配置_清风徐来,水波不兴

来源:互联网 

       配置内容

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://www.springframework.org/schema/beans"
    xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" 
    xmlns:p="https://www.springframework.org/schema/p"
    xmlns:context="https://www.springframework.org/schema/context"
    xmlns:mvc="https://www.springframework.org/schema/mvc" 
    xmlns:util="https://www.springframework.org/schema/util"
    xmlns:aop="https://www.springframework.org/schema/aop" 
    xmlns:tx="https://www.springframework.org/schema/tx"
    xsi:schemaLocation="https://www.springframework.org/schema/beans 
        https://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        https://www.springframework.org/schema/context 
        https://www.springframework.org/schema/context/spring-context-3.1.xsd
        https://www.springframework.org/schema/util 
        https://www.springframework.org/schema/util/spring-util-3.1.xsd
        https://www.springframework.org/schema/mvc 
        https://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd 
        https://www.springframework.org/schema/aop 
        https://www.springframework.org/schema/aop/spring-aop.xsd 
        https://www.springframework.org/schema/tx 
        https://www.springframework.org/schema/tx/spring-tx.xsd">

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

    <!--
    <bean id="webappdataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${webapp.jdbc.driverClassName}" />
        <property name="url" value="${webapp.jdbc.url}" />
        <property name="username" value="${webapp.jdbc.username}" />
        <property name="password" value="${webapp.jdbc.password}" />
    </bean>
    -->
    
    <bean id="webappdataSource" destroy-method="close"
        class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName" value="${webapp.jdbc.driverClassName}" />
        <property name="url" value="${webapp.jdbc.url}" />
        <property name="username" value="${webapp.jdbc.username}" />
        <property name="password" value="${webapp.jdbc.password}" />
        <property name="maxActive" value="${webapp.jdbc.maxActive}" />
        <property name="maxIdle" value="${webapp.jdbc.maxIdle}" />
        <property name="minIdle" value="${webapp.jdbc.minIdle}" />
        <property name="initialSize" value="${webapp.jdbc.initialSize}" />
        <property name="testOnBorrow" value="${webapp.jdbc.testOnBorrow}" />
        <property name="testWhileIdle" value="${webapp.jdbc.testWhileIdle}" />
        <property name="testOnReturn" value="${webapp.jdbc.testOnReturn}" />
        <property name="removeAbandoned" value="${webapp.jdbc.removeAbandoned}" />
        <property name="removeAbandonedTimeout" value="${webapp.jdbc.removeAbandonedTimeout}" />
        <property name="logAbandoned" value="${webapp.jdbc.logAbandoned}" />
        <property name="validationQuery" value="${webapp.jdbc.validationQuery}" />
    </bean>

    <!-- ============================== rrtong数据库配置  ==================================== -->    
    <bean id="rrtongDataSource" name="rrtongDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">
            <value>oracle.jdbc.driver.OracleDriver</value>
        </property>
        <property name="url">
            <value>jdbc:oracle:thin:@192.168.1.101:1521:orcl</value>
        </property>
        <property name="username">
            <value>rrtong</value>
        </property>
        <property name="password">
            <value>rrtong#ps007</value>
        </property>
    </bean> 

    <!-- ============================== 中心数据库配置  ==================================== -->        
    <bean id="centerDataSource" name="centerDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName">
            <value>oracle.jdbc.driver.OracleDriver</value>
        </property>
        <property name="url">
            <value>jdbc:oracle:thin:@192.168.1.102:1521:orcl</value>
        </property>
        <property name="username">
            <value>EDU_UCADM</value>
        </property>
        <property name="password">
            <value>pujinet2015</value>
        </property>
    </bean>

    <!-- memcached缓存客户端配置 -->
    <bean id="memcachedPool" class="com.schooner.MemCached.SchoonerSockIOPool" 
        factory-method="getInstance" init-method="initialize">
        <constructor-arg>
            <value>neeaMemcachedPool</value>
        </constructor-arg>
        <property name="servers">
            <list>
                <value>192.168.1.103:11211</value>
            </list>
        </property>
        <property name="initConn">
            <value>20</value>
        </property>
        <property name="minConn">
            <value>10</value>
        </property>
        <property name="maxConn">
            <value>50</value>
        </property>
        <property name="nagle">
            <value>false</value>
        </property>
        <property name="socketTO">
            <value>3000</value>
        </property>
    </bean>
    
    <bean id="memcachedClient" class="com.whalin.MemCached.MemCachedClient">
        <constructor-arg>
            <value>neeaMemcachedPool</value>
        </constructor-arg>
    </bean>
    
    <!-- redis访问配置 -->    
    <context:property-placeholder location="classpath:setup/redis.properties" />  
      
    <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">    
        <property name="maxTotal" value="${redis.pool.maxTotal}"></property>    
        <property name="maxIdle" value="${redis.pool.maxIdle}"></property>  
        <property name="minIdle" value="${redis.pool.minIdle}"></property>    
        <property name="maxWaitMillis" value="${redis.pool.maxWaitMillis}"></property>    
        <property name="minEvictableIdleTimeMillis" value="${redis.pool.minEvictableIdleTimeMillis}"></property>    
        <property name="numTestsPerEvictionRun" value="${redis.pool.numTestsPerEvictionRun}"></property>    
        <property name="timeBetweenEvictionRunsMillis" value="${redis.pool.timeBetweenEvictionRunsMillis}"></property>    
    </bean>    
  
    <bean id="shardedJedisPool" class="redis.clients.jedis.ShardedJedisPool"  scope="singleton" >  
        <constructor-arg index="0" ref="jedisPoolConfig" />  
        <constructor-arg index="1">  
            <list>  
                <bean name="master" class="redis.clients.jedis.JedisShardInfo">  
                    <constructor-arg name="host"    index="0" value="${redis.host}" />  
                    <constructor-arg name="port"    index="1" value="${redis.port}" type="int"/>  
                    <constructor-arg name="timeout" index="2" value="${redis.timeout}" type="int"/>  
                </bean>  
            </list>  
        </constructor-arg>  
    </bean> 
</beans>
<?xml version="1.0" encoding="UTF



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: