zoukankan      html  css  js  c++  java
  • 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>   
  • 相关阅读:
    Jmeter之Constant Timer与constant throughput timer的区别(转)
    JMeter Exception: java.net.BindException: Address already in use: connect(转)
    jmeter的jtl日志转html报告常见报错笔记
    jmeter 启动jmeter-server.bat远程调用报错: java.io.FileNotFoundException: rmi_keystore.jks (系统找不到指定的文件。)
    jmeter5.0生成html报告 快速入门
    图片转字符画 【学习ing】
    python生成个性二维码学习笔记
    Processing 3!
    Python Selenium定位元素常用解决办法
    js 获取元素坐标 和鼠标点击坐标
  • 原文地址:https://www.cnblogs.com/cmelody/p/6481779.html
Copyright © 2011-2022 走看看