1:修改mysql驱动包为5.1.35

2:更换mysql的连接池为druid
3:添加druid对spring的监控及添加webui的账号密码
4:添加astana的jdbc和app*-redis.xml的配置
This commit is contained in:
renkaige
2018-12-04 16:32:41 +06:00
parent feb178ef2a
commit cee08f35e7
6 changed files with 474 additions and 55 deletions

View File

@@ -32,30 +32,76 @@
class="org.springframework.jdbc.datasource.DriverManagerDataSource"></bean>
<!--数据源定义采用BoneCP连接池 ,业务配置服务数据库 -->
<bean id="ProductDataSource" parent="parentDataSource"
class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.log.driver}"></property>
<property name="jdbcUrl" value="${jdbc.log.url}"></property>
<property name="username" value="${jdbc.log.username}"></property>
<property name="password" value="${jdbc.log.password}"></property>
<!-- 检查数据库连接池中空闲连接的间隔时间单位是分默认值240如果要取消则设置为0 -->
<property name="idleConnectionTestPeriodInMinutes" value="${bonecp.idleConnectionTestPeriodInMinutes}"></property>
<!-- 连接池中未使用的链接最大存活时间单位是分默认值60如果要永远存活设置为0 -->
<property name="idleMaxAgeInMinutes" value="${bonecp.idleMaxAgeInMinutes}" />
<!-- 每个分区最大的连接数 -->
<property name="maxConnectionsPerPartition" value="${bonecp.maxConnectionsPerPartition}" />
<!-- 每个分区最小的连接数 -->
<property name="minConnectionsPerPartition" value="${bonecp.minConnectionsPerPartition}" />
<!-- 分区数 默认值2最小1推荐3-4视应用而定 -->
<property name="partitionCount" value="${bonecp.partitionCount}" />
<!-- 每次去拿数据库连接的时候一次性要拿几个,默认值2 -->
<property name="acquireIncrement" value="${bonecp.acquireIncrement}" />
<!-- 缓存prepared statements的大小默认值0 -->
<property name="statementsCacheSize" value="${bonecp.statementsCacheSize}" />
<bean id="ProductDataSource"
class="com.alibaba.druid.pool.DruidDataSource" init-method="init"
destroy-method="close">
<property name="driverClassName" value="${jdbc.log.driver}" />
<property name="url" value="${jdbc.log.url}" />
<property name="username" value="${jdbc.log.username}" />
<property name="password" value="${jdbc.log.password}" />
<!-- 配置初始化连接池数量 -->
<property name="initialSize" value="${druid.log.initialSize}" />
<!-- 配置最小连接池数量 -->
<property name="minIdle" value="${druid.log.minIdle}" />
<!-- 配置最大连接池数量 -->
<property name="maxActive" value="${druid.log.maxActive}" />
<!-- 配置获取连接等待超时的时间 单位毫秒 -->
<property name="maxWait" value="${druid.log.maxWait}" />
<!--使用非公平锁 -->
<property name="useUnfairLock"
value="${druid.log.useUnfairLock}" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis"
value="${druid.log.timeBetweenEvictionRunsMillis}" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis"
value="${druid.log.minEvictableIdleTimeMillis}" />
<!--用来检测连接是否有效的sql要求是一个查询语句。 -->
<property name="validationQuery"
value="${druid.log.mysql.validationQuery}" />
<!--申请连接的时候检测如果空闲时间大于timeBetweenEvictionRunsMillis执行validationQuery检测连接是否有效。 -->
<property name="testWhileIdle"
value="${druid.log.testWhileIdle}" />
<!--申请连接时执行validationQuery检测连接是否有效 -->
<property name="testOnBorrow"
value="${druid.log.testOnBorrow}" />
<!--归还连接时执行validationQuery检测连接是否有效 -->
<property name="testOnReturn"
value="${druid.log.testOnReturn}" />
<!-- 打开PSCache并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements"
value="${druid.log.poolPreparedStatements}" />
<!--要启用PSCache必须配置大于0当大于0时poolPreparedStatements自动触发修改为true。在Druid中不会存在Oracle下PSCache占用内存过多的问题可以把这个数值配置大一些比如说100 -->
<property name="maxOpenPreparedStatements"
value="${druid.log.maxOpenPreparedStatements}" />
<!-- 配置监控统计拦截的filters去掉后监控界面sql无法统计 -->
<property name="filters" value="${druid.log.filters}" />
<!-- 并在filters属性中配置了log4j -->
<property name="proxyFilters">
<list>
<ref bean="stat-filter" />
<ref bean="log-filter" />
</list>
</property>
<!--<property name="filters" value="mergeStat"/> -->
</bean>
<!-- 慢SQL记录 -->
<bean id="stat-filter"
class="com.alibaba.druid.filter.stat.StatFilter">
<property name="mergeSql" value="true" />
<property name="slowSqlMillis" value="10000" />
<property name="logSlowSql" value="true" />
</bean>
<bean id="log-filter"
class="com.alibaba.druid.filter.logging.Log4jFilter">
<property name="resultSetLogEnabled" value="false" />
<property name="statementExecutableSqlLogEnable" value="true" />
</bean>
<!--hive数据源定义采用BoneCP连接池 ,业务配置服务数据库 -->
<bean id="HiveDataSource" parent="parentDataSource"
class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close">

View File

@@ -0,0 +1,193 @@
<?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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:tool="http://www.springframework.org/schema/tool" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util" xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.1.xsd">
<!-- 加载配置文件,不知道为啥不能加载redis.properties的内容,先把redis.properties里面的内容放到jdbc.properties里面吧 -->
<context:property-placeholder
ignore-unresolvable="true" location="classpath:jdbc.properties" />
<bean id="poolConfig" class="redis.clients.jedis.JedisPoolConfig">
<property name="maxIdle" value="${redis.maxIdle}" />
<property name="maxTotal" value="${redis.maxTotal}" />
<property name="maxWaitMillis" value="${redis.maxWaitMillis}" />
<property name="testOnBorrow" value="${redis.testOnBorrow}" />
<property name="testOnReturn" value="${redis.testOnReturn}" />
</bean>
<bean id="jedisPool" class="redis.clients.jedis.JedisSentinelPool">
<constructor-arg name="masterName" value="mymaster" />
<constructor-arg name="sentinels">
<set>
<value>${redis.hostAndPort1}</value>
<value>${redis.hostAndPort2}</value>
<value>${redis.hostAndPort3}</value>
</set>
</constructor-arg>
<constructor-arg name="poolConfig" ref="poolConfig" />
<constructor-arg name="timeout"
value="${redis.timeout}" type="int" />
<!-- <constructor-arg name="password" value="${redis.pass}"/> -->
</bean>
<!-- <bean id="jedisCluster" class="com.nis.util.JedisClusterFactory"> -->
<!-- <property name="addressConfig"> -->
<!-- <value>classpath:jdbc.properties</value> -->
<!-- </property> -->
<!-- <property name="addressKeyPrefix" value="cluster" /> 属性文件里 key的前缀 -->
<!-- <property name="timeout" value="${redis.timeout}" /> -->
<!-- <property name="maxRedirections" value="${redis.maxRedirects}" /> -->
<!-- <property name="genericObjectPoolConfig" ref="poolConfig" /> -->
<!-- </bean> -->
<!-- redis集群 -->
<bean id="jedisCluster" class="redis.clients.jedis.JedisCluster" scope="prototype">
<constructor-arg index="0">
<set>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host1}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port1}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host1}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port2}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host1}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port3}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host1}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port4}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host2}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port1}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host2}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port2}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host2}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port3}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host2}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port4}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host3}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port1}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host3}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port2}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host3}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port3}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host3}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port4}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host4}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port1}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host4}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port2}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host4}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port3}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host4}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port4}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host5}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port1}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host5}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port2}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host5}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port3}"></constructor-arg>
</bean>
<bean class="redis.clients.jedis.HostAndPort">
<constructor-arg index="0"
value="${redis.cluster.host5}"></constructor-arg>
<constructor-arg index="1"
value="${redis.cluster.port4}"></constructor-arg>
</bean>
</set>
</constructor-arg>
<constructor-arg index="1" value="${redis.timeout}"></constructor-arg>
<constructor-arg index="2"
value="${redis.maxRedirects}"></constructor-arg>
<constructor-arg index="3" ref="poolConfig"></constructor-arg>
</bean>
</beans>

View File

@@ -0,0 +1,126 @@
#==========日志库 Mysql=======================
jdbc.log.driver=com.mysql.jdbc.Driver
#阿斯坦纳
jdbc.log.url=jdbc:mysql://10.0.4.22:8066/galaxy-service?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
jdbc.log.username=mycat
#实际密码ceiec2018!
jdbc.log.key=73FU0t+Z8+PUxD/PArzvkQ==
jdbc.log.password=lKZSz7h4AIhgKJb2l2GBMw==
#==================日志查询hive数据源信息==========================
#星汉hive数据源
jdbc.hive.driver=org.apache.hive.jdbc.HiveDriver
jdbc.hive.DBName=singhand_ntcstore
jdbc.hive.url=jdbc:hive2://218.76.55.165:30000/singhand_ntcstore
jdbc.hive.username=singhand
jdbc.hive.key=uKYTzWsRN1+X5Tt3W+CA4A==
jdbc.hive.password=f+IYYX73TPEqUp3fxLzxow==
bonecp.hive.idleMaxAgeInMinutes=60
bonecp.hive.idleConnectionTestPeriodInMinutes=240
bonecp.hive.maxConnectionsPerPartition=20
bonecp.hive.minConnectionsPerPartition=10
bonecp.hive.partitionCount=3
bonecp.hive.acquireIncrement=5
bonecp.hive.statementsCacheSize=100
#################日志查询clickhouse数据源信息#############
#日志查询是否使用clickhouse,否则使用hive
isUseClickHouse=true
##clickhouse数据库名称
jdbc.clickHouse.DBName=k18_ods
jdbc.clickhouse.driver=ru.yandex.clickhouse.ClickHouseDriver
#阿斯坦纳百分点的连接ip,需要配置域名与ip的对应关系10.4.41.109 clickhouse-read-ys.com
jdbc.clickhouse.url=jdbc:clickhouse://clickhouse-read-ys.com:80/k18_ods?socket_timeout=90000
jdbc.clickhouse.username=wall
#实际密码k18
jdbc.clickhouse.key=jT4yKPwwg2J4JE/KUZknnA==
jdbc.clickhouse.password=XmaxnU2yLPQ5dpWjY3RDjQ==
#########################配置日志查询使用druid连接池#########################################
#配置初始化连接池数量
druid.log.initialSize=5
#配置最小连接池数量
druid.log.minIdle=1
#配置最大连接池数量
druid.log.maxActive=200
# 配置获取连接等待超时的时间 单位毫秒
druid.log.maxWait=600000
#使用非公平锁
druid.log.useUnfairLock=true
#配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
druid.log.timeBetweenEvictionRunsMillis=60000
#配置一个连接在池中最小生存的时间,单位是毫秒
druid.log.minEvictableIdleTimeMillis=300000
#用来检测连接是否有效的sql要求是一个查询语句,下面是hive的
druid.log.hive.validationQuery=select unix_timestamp()
#用来检测连接是否有效的sql要求是一个查询语句,下面是clickhouse的
druid.log.clickHouse.validationQuery=show tables
#用来检测连接是否有效的sql要求是一个查询语句,下面是mysql的
druid.log.mysql.validationQuery=show tables
#申请连接的时候检测如果空闲时间大于timeBetweenEvictionRunsMillis执行validationQuery检测连接是否有效
druid.log.testWhileIdle=true
#申请连接时执行validationQuery检测连接是否有效
druid.log.testOnBorrow=true
#归还连接时执行validationQuery检测连接是否有效
druid.log.testOnReturn=false
#打开PSCache并且指定每个连接上PSCache的大小
druid.log.poolPreparedStatements=true
#要启用PSCache必须配置大于0当大于0时poolPreparedStatements自动触发修改为true。在Druid中不会存在Oracle下PSCache占用内存过多的问题可以把这个数值配置大一些比如说100
druid.log.maxOpenPreparedStatements=100
#配置监控统计拦截的filters去掉后监控界面sql无法统计
druid.log.filters=stat
#########################################################################
##minio地址
#########################################################################
##阿斯坦纳minio的地址,注意前面的http://不要忘记写
minio_url=http://10.0.7.7:9000
##minio的accessKey
minio_accessKey=minio
##minio的secretKey
minio_secretKey=123456789
##minio的bucketName
minio_bucketName=maat-redis
#####################################################################################################################################
##redis连接
#####################################################################################################################################
#阿斯坦纳
redis.hostAndPort1=10.0.7.1:26379
redis.hostAndPort2=10.0.7.2:26379
redis.hostAndPort3=10.0.7.3:26379
redis.pass=
#最大空闲连接数
redis.maxIdle=50
#最大连接数
redis.maxTotal=250
#获取连接时的最大等待毫秒数(如果设置为阻塞时BlockWhenExhausted),如果超时就抛异常, 小于零:阻塞不确定的时间, 默认-1
redis.maxWaitMillis=100000
#在获取连接的时候检查有效性
redis.testOnBorrow=true
#在归还连接的时候检查有效性
redis.testOnReturn=true
#客户端超时时间单位是毫秒
redis.timeout=100000
#用于 redis.clients.jedis.JedisCluster.JedisCluster(Set<HostAndPort>, int, int, GenericObjectPoolConfig) 第三个参数 maxRedirections
#默认值是5
#一般当此值设置过大时容易报Too many Cluster redirections
redis.maxRedirects=3
#3A-redis集群配置,如果需要执行数据同步需要在集群中执行LPUSH SyncRedisToCluster "1"
redis.cluster.host1=10.0.8.16
redis.cluster.host2=10.0.8.17
redis.cluster.host3=10.0.8.18
redis.cluster.host4=10.0.8.19
redis.cluster.host5=10.0.8.20
redis.cluster.port1=7001
redis.cluster.port2=7002
redis.cluster.port3=7003
redis.cluster.port4=7004

View File

@@ -1,10 +1,14 @@
<?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:p="http://www.springframework.org/schema/p"
xmlns:lang="http://www.springframework.org/schema/lang" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
@@ -39,17 +43,18 @@
cache-period="31536000" />
<!-- 定义无Controller的path<->view直接映射 -->
<mvc:view-controller path="/" view-name="redirect:/nis/index" />
<mvc:view-controller path="/"
view-name="redirect:/nis/index" />
<!-- 启用spring mvc注解 -->
<context:annotation-config />
<!-- 默认注解映射支持 -->
<mvc:annotation-driven />
<!-- 配置任务线性池 -->
<!-- 配置任务线性池 -->
<task:executor id="executor" pool-size="5"></task:executor>
<task:scheduler id="scheduler" pool-size="5"></task:scheduler>
<!-- 开启定时任务注解 -->
<!-- 开启定时任务注解 -->
<task:annotation-driven scheduler="scheduler"
executor="executor" />
@@ -59,7 +64,8 @@
<!-- redis 工具类 -->
<bean id="redisDao" class="com.nis.util.redis.RedisDao" />
<!-- elasticsearch 工具类 将查询转化为elasticsearch-sql支持的语法 -->
<bean id="elasticsearchSqlDao" class="com.nis.util.elasticsearch.ElasticsearchSqlDao" />
<bean id="elasticsearchSqlDao"
class="com.nis.util.elasticsearch.ElasticsearchSqlDao" />
<!-- 定义httpclient连接池 -->
<bean id="httpClientConnectionManager"
class="org.apache.http.impl.conn.PoolingHttpClientConnectionManager"
@@ -67,13 +73,16 @@
<!-- 设置连接总数 -->
<property name="maxTotal" value="${http.pool.maxTotal}"></property>
<!-- 设置每个地址的并发数 -->
<property name="defaultMaxPerRoute" value="${http.pool.defaultMaxPerRoute}"></property>
<property name="defaultMaxPerRoute"
value="${http.pool.defaultMaxPerRoute}"></property>
</bean>
<!-- 定义 HttpClient工厂这里使用HttpClientBuilder构建 -->
<bean id="httpClientBuilder" class="org.apache.http.impl.client.HttpClientBuilder"
<bean id="httpClientBuilder"
class="org.apache.http.impl.client.HttpClientBuilder"
factory-method="create">
<property name="connectionManager" ref="httpClientConnectionManager"></property>
<property name="connectionManager"
ref="httpClientConnectionManager"></property>
</bean>
<!-- 得到httpClient的实例 -->
@@ -83,41 +92,53 @@
<!-- 定期清理无效的连接 -->
<bean class="com.nis.util.httpclient.IdleConnectionEvictor"
destroy-method="shutdown">
<constructor-arg index="0" ref="httpClientConnectionManager" />
<constructor-arg index="0"
ref="httpClientConnectionManager" />
<!-- 间隔一分钟清理一次 -->
<constructor-arg index="1" value="60000" />
</bean>
<!-- 定义requestConfig的工厂 -->
<bean id="requestConfigBuilder" class="org.apache.http.client.config.RequestConfig.Builder">
<bean id="requestConfigBuilder"
class="org.apache.http.client.config.RequestConfig.Builder">
<!-- 从连接池中获取到连接的最长时间 -->
<property name="connectionRequestTimeout" value="${http.request.connectionRequestTimeout}" />
<property name="connectionRequestTimeout"
value="${http.request.connectionRequestTimeout}" />
<!-- 创建连接的最长时间 -->
<property name="connectTimeout" value="${http.request.connectTimeout}" />
<property name="connectTimeout"
value="${http.request.connectTimeout}" />
<!-- 数据传输的最长时间 -->
<property name="socketTimeout" value="${http.request.socketTimeout}" />
<property name="socketTimeout"
value="${http.request.socketTimeout}" />
<!-- 提交请求前测试连接是否可用 -->
<property name="staleConnectionCheckEnabled" value="${http.request.staleConnectionCheckEnabled}" />
<property name="staleConnectionCheckEnabled"
value="${http.request.staleConnectionCheckEnabled}" />
</bean>
<!-- 得到requestConfig实例 -->
<bean id="requestConfig" factory-bean="requestConfigBuilder"
factory-method="build" />
<!--事务控制驱动注解,发现注解@Transactional 时找transactionManager事务管理器 -->
<tx:annotation-driven transaction-manager="transactionManager" />
<tx:annotation-driven
transaction-manager="transactionManager" />
<!-- autodetection of such annotated controllers -->
<context:component-scan base-package="com.nis.web"></context:component-scan>
<context:component-scan base-package="com.nis.restful"></context:component-scan>
<context:component-scan base-package="com.nis.test"></context:component-scan>
<context:component-scan
base-package="com.nis.web"></context:component-scan>
<context:component-scan
base-package="com.nis.restful"></context:component-scan>
<context:component-scan
base-package="com.nis.test"></context:component-scan>
<!-- 默认的注解映射的支持org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping -->
<mvc:annotation-driven
content-negotiation-manager="contentNegotiationManager">
<mvc:message-converters register-defaults="true">
<mvc:message-converters
register-defaults="true">
<!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8" />
</bean>
<!-- 将Jackson2HttpMessageConverter的默认格式化输出为false -->
@@ -137,7 +158,8 @@
<bean
class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<constructor-arg>
<bean class="org.springframework.oxm.xstream.XStreamMarshaller">
<bean
class="org.springframework.oxm.xstream.XStreamMarshaller">
<property name="streamDriver">
<bean class="com.thoughtworks.xstream.io.xml.StaxDriver" />
</property>
@@ -151,7 +173,8 @@
</property>
</bean>
</constructor-arg>
<property name="supportedMediaTypes" value="application/xml"></property>
<property name="supportedMediaTypes"
value="application/xml"></property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
@@ -177,9 +200,12 @@
<mvc:exclude-mapping path="/nis/login" />
<mvc:exclude-mapping path="/nis/sys/index" />
<mvc:exclude-mapping path="/nis/sys/menu/tree" />
<mvc:exclude-mapping path="/nis/sys/menu/treeData" />
<mvc:exclude-mapping path="/nis/sys/user/getToDoTaskNum" />
<mvc:exclude-mapping path="/nis/sys/user/toDoTask" />
<mvc:exclude-mapping
path="/nis/sys/menu/treeData" />
<mvc:exclude-mapping
path="/nis/sys/user/getToDoTaskNum" />
<mvc:exclude-mapping
path="/nis/sys/user/toDoTask" />
<bean class="com.nis.interceptor.LogInterceptor" />
</mvc:interceptor>
<!-- 添加restful服务的过滤 -->
@@ -238,14 +264,17 @@
<property name="order" value="0" />
</bean>
<bean id="RestServiceExceptionHandler" class="com.nis.restful.AppExceptionHandler">
<bean id="RestServiceExceptionHandler"
class="com.nis.restful.AppExceptionHandler">
<property name="order" value="1" />
<property name="errorResolver">
<bean class="com.nis.restful.DefaultRestErrorResolver">
<property name="exceptionMappingDefinitions">
<map>
<entry key="com.nis.restful.RestServiceException" value="400" />
<entry key="com.nis.restful.ServiceRuntimeException" value="500" />
<entry key="com.nis.restful.RestServiceException"
value="400" />
<entry key="com.nis.restful.ServiceRuntimeException"
value="500" />
<entry key="Throwable" value="500" />
</map>
</property>
@@ -276,8 +305,23 @@
<property name="uploadTempDir" value="/upload"></property>
</bean>
<!-- 设置druid对spring的监控 -->
<bean id="druid-stat-interceptor"
class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor" />
<bean id="druid-stat-pointcut"
class="org.springframework.aop.support.JdkRegexpMethodPointcut"
scope="prototype">
<property name="patterns">
<list>
<value>com.nis.web.service.*</value>
<value>com.nis.web.dao.*</value>
</list>
</property>
</bean>
<aop:config proxy-target-class="true">
<aop:advisor advice-ref="druid-stat-interceptor"
pointcut-ref="druid-stat-pointcut" />
</aop:config>
</beans>

View File

@@ -179,6 +179,16 @@
<servlet>
<servlet-name>DruidStatView</servlet-name>
<servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
<init-param>
<!-- 用户名 -->
<param-name>loginUsername</param-name>
<param-value>galaxy</param-value>
</init-param>
<init-param>
<!-- 密码 -->
<param-name>loginPassword</param-name>
<param-value>k18ceiec</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>DruidStatView</servlet-name>