gaodm 4 роки тому
батько
коміт
c557df3750

+ 5 - 5
pom.xml

@@ -160,11 +160,11 @@
         <!-- mybatis-plus end -->
 
         <!-- 阿里巴巴druid数据库连接池 -->
-        <!--<dependency>-->
-            <!--<groupId>com.alibaba</groupId>-->
-            <!--<artifactId>druid-spring-boot-starter</artifactId>-->
-            <!--<version>${druid.version}</version>-->
-        <!--</dependency>-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid-spring-boot-starter</artifactId>
+            <version>${druid.version}</version>
+        </dependency>
 
         <!-- springboot整合mybatis(核心就这一个) -->
         <!-- 注意顺序,这个一定要放在最下面 -->

+ 2 - 1
src/main/java/com/diagbot/CdssCoreApplication.java

@@ -1,5 +1,6 @@
 package com.diagbot;
 
+import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@@ -19,7 +20,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
  * @time: 2018/8/7 9:26
  */
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
-        JmxAutoConfiguration.class, ThymeleafAutoConfiguration.class })
+        JmxAutoConfiguration.class, ThymeleafAutoConfiguration.class, DruidDataSourceAutoConfigure.class })
 @EnableFeignClients({ "com.diagbot.client" })
 @EnableHystrix
 @EnableHystrixDashboard

+ 45 - 0
src/main/resources/application-dev.yml

@@ -39,6 +39,47 @@ spring:
   datasource:
     dynamic:
       primary: med
+      druid:
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        initialSize: 5
+        minIdle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters.commons-log.connection-logger-name: wall,log4j
+        share-prepared-statements: true
+        filter:
+          stat:
+            enabled: true
+            mergeSql: true
+            log-slow-sql: true
+            slow-sql-millis: 2000
+        #监控配置
+        web-stat-filter:
+          enabled: true
+          url-pattern: /*
+          exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
+
+        # StatViewServlet配置,说明请参考Druid Wiki,配置_StatViewServlet配置
+        stat-view-servlet:
+          enabled: true
+          url-pattern: /druid/*
+          reset-enable: false
+          login-username: root
+          login-password: root
       # 数据库配置
       datasource:
         cdss:
@@ -47,12 +88,16 @@ spring:
           url: jdbc:mysql://192.168.2.236:3306/cdss?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: root
           password: lantone
+          druid:
+            initial-size: 5
         med:
           driver-class-name: com.mysql.cj.jdbc.Driver
           platform: mysql
           url: jdbc:mysql://192.168.2.236:3306/med_2021?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: root
           password: lantone
+          druid:
+            initial-size: 5
 
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss

+ 45 - 0
src/main/resources/application-local.yml

@@ -39,6 +39,47 @@ spring:
   datasource:
     dynamic:
       primary: med
+      druid:
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        initialSize: 5
+        minIdle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters.commons-log.connection-logger-name: wall,log4j
+        share-prepared-statements: true
+        filter:
+          stat:
+            enabled: true
+            mergeSql: true
+            log-slow-sql: true
+            slow-sql-millis: 2000
+        #监控配置
+        web-stat-filter:
+          enabled: true
+          url-pattern: /*
+          exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
+
+        # StatViewServlet配置,说明请参考Druid Wiki,配置_StatViewServlet配置
+        stat-view-servlet:
+          enabled: true
+          url-pattern: /druid/*
+          reset-enable: false
+          login-username: root
+          login-password: root
       # 数据库配置
       datasource:
         cdss:
@@ -47,12 +88,16 @@ spring:
           url: jdbc:mysql://192.168.2.236:3306/cdss?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: root
           password: lantone
+          druid:
+            initial-size: 5
         med:
           driver-class-name: com.mysql.cj.jdbc.Driver
           platform: mysql
           url: jdbc:mysql://192.168.2.236:3306/med_2021?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: root
           password: lantone
+          druid:
+            initial-size: 5
 
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss

+ 45 - 0
src/main/resources/application-pre.yml

@@ -41,18 +41,63 @@ spring:
       primary: med
       # 数据库配置
       datasource:
+        druid:
+          # 连接池的配置信息
+          # 初始化大小,最小,最大
+          initialSize: 5
+          minIdle: 5
+          maxActive: 20
+          # 配置获取连接等待超时的时间
+          maxWait: 60000
+          # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+          timeBetweenEvictionRunsMillis: 60000
+          # 配置一个连接在池中最小生存的时间,单位是毫秒
+          minEvictableIdleTimeMillis: 300000
+          validationQuery: SELECT 1 FROM DUAL
+          testWhileIdle: true
+          testOnBorrow: false
+          testOnReturn: false
+          # 打开PSCache,并且指定每个连接上PSCache的大小
+          poolPreparedStatements: true
+          maxPoolPreparedStatementPerConnectionSize: 20
+          # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+          filters.commons-log.connection-logger-name: wall,log4j
+          share-prepared-statements: true
+          filter:
+            stat:
+              enabled: true
+              mergeSql: true
+              log-slow-sql: true
+              slow-sql-millis: 2000
+          #监控配置
+          web-stat-filter:
+            enabled: true
+            url-pattern: /*
+            exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
+
+          # StatViewServlet配置,说明请参考Druid Wiki,配置_StatViewServlet配置
+          stat-view-servlet:
+            enabled: true
+            url-pattern: /druid/*
+            reset-enable: false
+            login-username: root
+            login-password: root
         cdss:
           driver-class-name: com.mysql.cj.jdbc.Driver
           platform: mysql
           url: jdbc:mysql://192.168.2.121:3306/cdss?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: teamback
           password: goTulmLeon
+          druid:
+            initial-size: 5
         med:
           driver-class-name: com.mysql.cj.jdbc.Driver
           platform: mysql
           url: jdbc:mysql://192.168.2.121:3306/med_2021?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: teamback
           password: goTulmLeon
+          druid:
+            initial-size: 5
 
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss

+ 45 - 0
src/main/resources/application-pro.yml

@@ -39,6 +39,47 @@ spring:
   datasource:
     dynamic:
       primary: med
+      druid:
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        initialSize: 5
+        minIdle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters.commons-log.connection-logger-name: wall,log4j
+        share-prepared-statements: true
+        filter:
+          stat:
+            enabled: true
+            mergeSql: true
+            log-slow-sql: true
+            slow-sql-millis: 2000
+        #监控配置
+        web-stat-filter:
+          enabled: true
+          url-pattern: /*
+          exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
+
+        # StatViewServlet配置,说明请参考Druid Wiki,配置_StatViewServlet配置
+        stat-view-servlet:
+          enabled: true
+          url-pattern: /druid/*
+          reset-enable: false
+          login-username: root
+          login-password: root
       # 数据库配置
       datasource:
         cdss:
@@ -47,12 +88,16 @@ spring:
           url: jdbc:mysql://192.168.2.122:3306/cdss?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: root
           password: lantone
+          druid:
+            initial-size: 5
         med:
           driver-class-name: com.mysql.cj.jdbc.Driver
           platform: mysql
           url: jdbc:mysql://192.168.2.122:3306/med_2021?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: root
           password: lantone
+          druid:
+            initial-size: 5
 
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss

+ 45 - 0
src/main/resources/application-test.yml

@@ -39,6 +39,47 @@ spring:
   datasource:
     dynamic:
       primary: med
+      druid:
+        # 连接池的配置信息
+        # 初始化大小,最小,最大
+        initialSize: 5
+        minIdle: 5
+        maxActive: 20
+        # 配置获取连接等待超时的时间
+        maxWait: 60000
+        # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
+        timeBetweenEvictionRunsMillis: 60000
+        # 配置一个连接在池中最小生存的时间,单位是毫秒
+        minEvictableIdleTimeMillis: 300000
+        validationQuery: SELECT 1 FROM DUAL
+        testWhileIdle: true
+        testOnBorrow: false
+        testOnReturn: false
+        # 打开PSCache,并且指定每个连接上PSCache的大小
+        poolPreparedStatements: true
+        maxPoolPreparedStatementPerConnectionSize: 20
+        # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
+        filters.commons-log.connection-logger-name: wall,log4j
+        share-prepared-statements: true
+        filter:
+          stat:
+            enabled: true
+            mergeSql: true
+            log-slow-sql: true
+            slow-sql-millis: 2000
+        #监控配置
+        web-stat-filter:
+          enabled: true
+          url-pattern: /*
+          exclusions: '*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*'
+
+        # StatViewServlet配置,说明请参考Druid Wiki,配置_StatViewServlet配置
+        stat-view-servlet:
+          enabled: true
+          url-pattern: /druid/*
+          reset-enable: false
+          login-username: root
+          login-password: root
       # 数据库配置
       datasource:
         cdss:
@@ -47,12 +88,16 @@ spring:
           url: jdbc:mysql://192.168.2.241:3306/cdss?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: root
           password: lantone
+          druid:
+            initial-size: 5
         med:
           driver-class-name: com.mysql.cj.jdbc.Driver
           platform: mysql
           url: jdbc:mysql://192.168.2.241:3306/med_2021?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false&allowMultiQueries=true&rewriteBatchedStatements=true
           username: root
           password: lantone
+          druid:
+            initial-size: 5
 
   jackson:
     date-format: yyyy-MM-dd HH:mm:ss