Sfoglia il codice sorgente

实现适配器多数据源

shilin 2 anni fa
parent
commit
74167d11c7

+ 11 - 2
realtime/healthmodel-server-cph/pom.xml

@@ -22,7 +22,7 @@
         <commons.io.version>2.5</commons.io.version>
         <groovy.version>3.0.8</groovy.version>
         <spring-boot.version>2.3.7.RELEASE</spring-boot.version>
-
+        <pgsql.version>42.2.5</pgsql.version>
     </properties>
     <dependencies>
 
@@ -119,7 +119,11 @@
 
         </dependency>
 
-
+        <dependency>
+            <groupId>org.postgresql</groupId>
+            <artifactId>postgresql</artifactId>
+            <version>${pgsql.version}</version>
+        </dependency>
         <!-- ********************** plugin ********************** -->
         <!-- groovy-all -->
         <dependency>
@@ -142,6 +146,11 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.3.7.RELEASE</version>
+                <configuration>
+                    <!--maven编译时将本地引用的jar包一起打包-->
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
                 <executions>
                     <execution>
                         <goals>

+ 20 - 42
realtime/healthmodel-server-cph/src/main/resources/application-jn.yml

@@ -37,49 +37,27 @@ spring:
     exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
   datasource:
     type: com.alibaba.druid.pool.DruidDataSource
-    #    driverClassName: com.mysql.jdbc.Driver
-    #druid连接池配置
+    #外网
+    url: jdbc:postgresql://10.81.3.151:5432/wisdom
+    username: gdprod
+    password: gd123
+    driver-class-name: org.postgresql.Driver
+    oracle-schema=:
+    #    type: com.alibaba.druid.pool.DruidDataSource
+    #    url: jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf8&serverTimezone=UTC
+    #    username: root
+    #    password: root
+    #    driver-class-name: com.mysql.jdbc.Driver
     druid:
-      #主库数据源
-      master:
-        url: jdbc:postgresql://10.81.3.151:5432/wisdom
-        username: gdprod
-        password: gd123
-        driver-class-name: org.postgresql.Driver
-      #备数据源 #关闭
-      slave:
-#        enabled: false
-#        url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&serverTimezone=UTC
-#        username: root
-#        password: 123456
-        #两票数据源
-      ticket:
-#        #url: jdbc:sqlserver://10.0.118.71:1433;DatabaseName=fdeamnew
-#        #url: jdbc:sqlserver://123.60.213.70:1434;DatabaseName=fdeam
-#        url: jdbc:sqlserver://192.168.2.200:1434;DatabaseName=fdeamnew
-#        username: sa
-#        password: ibs
-#        #password: Gd!123456
-#        #        password: Gyee@321#!
-#        #        password: ibs
-#        driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
-        #配置初始化连接数大小
-      initial-size: 10
-      # 最大连接数
-      max-active: 50
-      #最小连接数
-      min-idle: 10
-      #获取连接等待超时时间
-      max-wait: 5000
-      pool-prepared-statements: true #是否缓存preparedStatement,也就是PSCache。PSCache对支持游标的数据库性能提升巨大,比如说oracle。在mysql下建议关闭。
-      max-pool-prepared-statement-per-connection-size: 20
-      validation-query: SELECT 1 FROM DUAL
-      validation-query-timeout: 20000
-      test-on-borrow: false #申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
-      test-on-return: false #归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。
-      test-while-idle: true #建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。
-      time-between-eviction-runs-millis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
-      min-evictable-idle-time-millis: 300000  #一个连接在池中最小生存的时间,单位是毫秒
+      max-active: 20
+      initial-size: 1
+      min-idle: 3
+      max-wait: 60000
+      time-between-eviction-runs-millis: 60000
+      min-evictable-idle-time-millis: 300000
+      test-while-idle: true
+      test-on-borrow: false
+      test-on-return: false
       #StatViewServlet配置。(因为暴露的监控信息比较敏感,支持密码加密和访问ip限定)
       stat-view-servlet:
         enabled: true

+ 1 - 1
realtime/healthmodel-server-cph/src/main/resources/application.yml

@@ -1,4 +1,4 @@
 spring:
   profiles:
-    active: hb
+    active: jn
 #    active: jn

+ 3 - 3
realtime/healthmodel-server-cph/src/main/resources/xxl-job-executor.properties

@@ -1,6 +1,6 @@
 ### xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
-xxl.job.admin.addresses=http://192.168.2.198:8175/xxl-job-admin
-
+##xxl.job.admin.addresses=http://192.168.2.198:8175/xxl-job-admin
+xxl.job.admin.addresses=http://10.81.3.152:8175/xxl-job-admin
 ### xxl-job, access token
 xxl.job.accessToken=
 
@@ -10,7 +10,7 @@ xxl.job.executor.appname=healthmodel-job
 xxl.job.executor.address=
 ### xxl-job executor server-info
 xxl.job.executor.ip=
-xxl.job.executor.port=9103
+xxl.job.executor.port=9113
 ### xxl-job executor log-path
 xxl.job.executor.logpath=d:\\jobs\\healthmodel-job
 ### xxl-job executor log-retention-days