Quellcode durchsuchen

替换hikariCP为Druid

lighter vor 3 Jahren
Ursprung
Commit
f05bec404d

+ 15 - 4
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>7.1</version>
+    <version>7.2</version>
     <name>wxservice-server</name>
     <description>server for wxservice-web</description>
 
@@ -45,11 +45,22 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-jdbc</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.tomcat</groupId>
+                    <artifactId>tomcat-jdbc</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
-            <groupId>net.sourceforge.jtds</groupId>
-            <artifactId>jtds</artifactId>
-            <version>1.3.1</version>
+            <groupId>com.microsoft.sqlserver</groupId>
+            <artifactId>mssql-jdbc</artifactId>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.2.8</version>
         </dependency>
         <dependency>
             <groupId>org.projectlombok</groupId>

+ 24 - 13
src/main/resources/application-8083.yml

@@ -8,19 +8,30 @@ spring:
   thymeleaf:
     cache: false
   datasource:
-    url: jdbc:jtds:sqlserver://172.16.32.168:1433/thxyhisdb
-    hikari:
-      username: sa
-      password:
-      minimum-idle: 10
-      idle-timeout: 60000
-      maximum-pool-size: 30
-      auto-commit: true
-      pool-name: DJHikariCP
-      connection-timeout: 30000
-      validation-timeout: 3000
-      max-lifetime: 60000
-      leak-detection-threshold: 6000
+    url: jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb
+    username: sa
+    password:
+    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
+    type: com.alibaba.druid.pool.DruidDataSource
+    durid:
+      initial-size: 10
+      max-active: 40
+      min-idle: 10
+      max-wait: 60000
+      validation-query: SELECT 1
+      test-while-idle: true
+      test-on-borrow: false
+      test-on-return: false
+      time-between-eviction-runs-millis: 60000
+      min-evictable-idle-time-millis: 300000
+      filters: stat
+      pool-prepared-statements: false
+      max-pool-prepared-statement-per-connection-size: 200
+      remove-abandoned: true
+      remove-abandoned-timeout: 180
+      log-abandoned: true
+    autoconfigure:
+      exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 去除druid配置
   jackson:
     time-zone: GMT+8
     date-format: yyyy-MM-dd HH:mm:ss

+ 24 - 13
src/main/resources/application-8085.yml

@@ -8,19 +8,30 @@ spring:
   thymeleaf:
     cache: false
   datasource:
-    url: jdbc:jtds:sqlserver://172.16.32.168:1433/thxyhisdb
-    hikari:
-      username: sa
-      password:
-      minimum-idle: 10
-      idle-timeout: 60000
-      maximum-pool-size: 30
-      auto-commit: true
-      pool-name: DJHikariCP
-      connection-timeout: 30000
-      validation-timeout: 3000
-      max-lifetime: 60000
-      leak-detection-threshold: 6000
+    url: jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb
+    username: sa
+    password:
+    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
+    type: com.alibaba.druid.pool.DruidDataSource
+    durid:
+      initial-size: 10
+      max-active: 40
+      min-idle: 10
+      max-wait: 60000
+      validation-query: SELECT 1
+      test-while-idle: true
+      test-on-borrow: false
+      test-on-return: false
+      time-between-eviction-runs-millis: 60000
+      min-evictable-idle-time-millis: 300000
+      filters: stat
+      pool-prepared-statements: false
+      max-pool-prepared-statement-per-connection-size: 200
+      remove-abandoned: true
+      remove-abandoned-timeout: 180
+      log-abandoned: true
+    autoconfigure:
+      exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 去除druid配置
   jackson:
     time-zone: GMT+8
     date-format: yyyy-MM-dd HH:mm:ss

+ 24 - 12
src/main/resources/application.yml

@@ -8,18 +8,30 @@ spring:
   thymeleaf:
     cache: false
   datasource:
-#    url: jdbc:jtds:sqlserver://172.16.32.179:1433/thxyhisdb
-    url: jdbc:jtds:sqlserver://172.16.32.168:1433/thxyhisdb
-    hikari:
-      username: sa
-      password:
-      minimum-idle: 5
-      idle-timeout: 180000
-      maximum-pool-size: 8
-      auto-commit: true
-      pool-name: MyHikariCP
-      connection-timeout: 30000
-      connection-test-query: select 1
+    url: jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb
+    username: sa
+    password:
+    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
+    type: com.alibaba.druid.pool.DruidDataSource
+    durid:
+      initial-size: 10
+      max-active: 40
+      min-idle: 10
+      max-wait: 60000
+      validation-query: SELECT 1
+      test-while-idle: true
+      test-on-borrow: false
+      test-on-return: false
+      time-between-eviction-runs-millis: 60000
+      min-evictable-idle-time-millis: 300000
+      filters: stat
+      pool-prepared-statements: false
+      max-pool-prepared-statement-per-connection-size: 200
+      remove-abandoned: true
+      remove-abandoned-timeout: 180
+      log-abandoned: true
+    autoconfigure:
+      exclude: com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 去除druid配置
   jackson:
     time-zone: GMT+8
     date-format: yyyy-MM-dd HH:mm:ss