• Spring核心配置


    头文件

    <?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:p="http://www.springframework.org/schema/p"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        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/context
            http://www.springframework.org/schema/context/spring-context.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
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx.xsd
            ">
    
    
    </beans>

    引入jdbc.properties文件

    <context:property-placeholder location="classpath:jdbc.properties"/>    

    配置dataSource

    <bean id="dataSource" 
            class="org.apache.commons.dbcp.BasicDataSource"
            destroy-method="close" scope="singleton">
            
            <property name="driverClassName" value="${jdbc.driverClassName}" />
            <property name="url" value="${jdbc.url}" />
            <property name="username" value="${jdbc.username}" />
            <property name="password" value="${jdbc.password}" />
            
            <property name="initialSize" value="${jdbc.initialSize}" />
            <property name="maxActive" value="${jdbc.maxActive}" />
            <property name="maxIdle" value="${jdbc.maxIdle}" />
            <property name="minIdle" value="${jdbc.minIdle}" />
            <property name="maxWait" value="${jdbc.maxWait}" />
            <property name="removeAbandoned" value="${jdbc.removeAbandoned}" />
            <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}" />
            
            <property name="testWhileIdle" value="true" />
            <property name="timeBetweenEvictionRunsMillis" value="60000" />
            
            <property name="testOnBorrow" value="false" />
            <property name="testOnReturn" value="false" />
            <property name="validationQuery" value="select 1" />
            <property name="numTestsPerEvictionRun" value="${jdbc.maxActive}" />
    </bean>

     配置redis

        <!-- redis配置 -->
            <!-- 在redis.jar的2.4版本以上时,maxActive->maxTotal
        maxWait->maxWaitMills -->
        <bean id="jedisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
            <property name="maxTotal" value="90" />
            <property name="maxIdle" value="5" />
            <property name="maxWaitMillis" value="1000" />
            <property name="testOnBorrow" value="true" />
        </bean>
        <bean id="jedisPool" class="redis.clients.jedis.JedisPool" destroy-method="destroy">
            <constructor-arg ref="jedisPoolConfig" />
            <constructor-arg value="/*redis安装位置IP*/" />
            <constructor-arg value="/*redis端口号,默认6379*/6379" />
        </bean>
        <bean id="redisAPI" class="/*redis的实现类*/">
            <property name="jedisPool" ref="jedisPool" />
        </bean>   
  • 相关阅读:
    理解老板是治疗职场心态最好的药
    给青年创业者, 风险投资的十大谎言
    在尊重人的基础上发展人
    预付费
    提高记忆力的最好方法是进行记忆力训练
    九绝招巧妙应付职场各类人
    写在深夜下班路上
    25岁不得不想的问题
    谈IT技术人员的创业转摘
    职场沟通必备8个黄金句型
  • 原文地址:https://www.cnblogs.com/cmelody/p/6481779.html
Copyright © 2020-2023  润新知