From 0fa5700b33caf07110fb546a6df7793ee246feca Mon Sep 17 00:00:00 2001 From: erdanergou Date: Tue, 25 Jul 2023 16:26:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 11 ++- .../DepositoryManageApplication.java | 4 +- src/main/resources/application-prod.yml | 89 +++++++++--------- src/main/resources/application-test.yml | 90 +++++++++---------- 4 files changed, 98 insertions(+), 96 deletions(-) diff --git a/pom.xml b/pom.xml index 11957ce1..d6eee238 100644 --- a/pom.xml +++ b/pom.xml @@ -54,6 +54,13 @@ 3.2.0 + + log4j + log4j + 1.2.14 + compile + + ch.qos.logback logback-classic @@ -65,8 +72,8 @@ com.alibaba - druid - 1.1.14 + druid-spring-boot-starter + 1.2.6 org.projectlombok diff --git a/src/main/java/com/dreamchaser/depository_manage/DepositoryManageApplication.java b/src/main/java/com/dreamchaser/depository_manage/DepositoryManageApplication.java index bfa1cebb..535f068e 100644 --- a/src/main/java/com/dreamchaser/depository_manage/DepositoryManageApplication.java +++ b/src/main/java/com/dreamchaser/depository_manage/DepositoryManageApplication.java @@ -1,11 +1,13 @@ package com.dreamchaser.depository_manage; +import com.alibaba.druid.pool.xa.DruidXADataSource; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; -@SpringBootApplication +@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class) public class DepositoryManageApplication extends SpringBootServletInitializer { public static void main(String[] args) { diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index d714b24d..704e115f 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -1,13 +1,13 @@ #开启健康检查、审计、统计和监控,即可通过访问/actuator/beans等查看状态 management: endpoints: - web: - exposure: - include: beans,health + web: + exposure: + include: beans,health spring: mobile: sitepreference: - enabled:true + enabled: true servlet: multipart: @@ -16,41 +16,46 @@ spring: max-request-size: 100MB # 一次请求总大小上限 ##数据库设置 datasource: - dynamic: - druid: - initialSize: 5 # 初始连接数 - minIdle: 5 # 最小空闲数 - maxActive: 20 #最大活跃连接数 - maxWait: 60000 #获取连接的最大等待时间(毫秒) - timeBetweenEvictionRunsMillis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - minEvictableIdleTimeMillis: 300000 #配置一个连接在池中最小生存的时间,单位是毫秒 - useGlobalDataSourceStat: true - testWhileIdle: true - testOnReturn: false - testOnBorrow: false - poolPreparedStatements: true - maxPoolPreparedStatementPerConnectionSize: 20 - #配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙 - filters: stat, wall, log4j - connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 - #超时回收机制 - removeAbandoned: true - removeAbandonedTimeout: 1800 - logAbandoned: true - datasource: - master: - username: depository # 用户名 - password: NhE47edekBHxhjYk #密码 - url: jdbc:mysql://127.0.0.1:3306/depository?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8 - driver-class-name: com.mysql.cj.jdbc.Driver #driver - type: com.alibaba.druid.pool.DruidDataSource + dynamic: + strict: false + primary: master # 配置默认数据库 + datasource: + master: + username: depository # 用户名 + password: NhE47edekBHxhjYk #密码 + url: jdbc:mysql://127.0.0.1:3306/depository?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8 + driver-class-name: com.mysql.cj.jdbc.Driver #驱动 + type: com.alibaba.druid.pool.DruidDataSource + + hr_new: + username: hr_new + password: AnknKiXiXaxNrw78 + url: jdbc:mysql://127.0.0.1:3306/hr_new?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8 + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.alibaba.druid.pool.DruidDataSource + druid: + initialSize: 5 # 初始连接数 + minIdle: 5 # 最小空闲数 + maxActive: 20 #最大活跃连接数 + maxWait: 60000 #获取连接的最大等待时间(毫秒) + timeBetweenEvictionRunsMillis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + minEvictableIdleTimeMillis: 300000 #配置一个连接在池中最小生存的时间,单位是毫秒 + useGlobalDataSourceStat: true + testWhileIdle: true + testOnReturn: false + testOnBorrow: false + poolPreparedStatements: true + maxPoolPreparedStatementPerConnectionSize: 20 + #配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙 + filters: stat, wall, log4j + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + #超时回收机制 + removeAbandoned: true + removeAbandonedTimeout: 1800 + logAbandoned: true + + - hr_new: - username: hr_new - password: AnknKiXiXaxNrw78 - url: jdbc:mysql://127.0.0.1:3306/hr_new?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8 - driver-class-name: com.mysql.cj.jdbc.Driver - type: com.alibaba.druid.pool.DruidDataSource banner: location: banner.txt @@ -77,20 +82,12 @@ spring: max-active: 200 timeout: 2000ms - redisPool: port: 6379 host: 127.0.0.1 dbs: 5,14,15 password: -server: -mybatis: - type-aliases-package: com.dreamchaser.depository_manage.entity - configuration: - log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl - log-prefix: mapper. - mybatis-plus: mapper-locations: classpath*:*_mapper/*Mapper.xml diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 9caeeda9..488807fd 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -1,9 +1,9 @@ #开启健康检查、审计、统计和监控,即可通过访问/actuator/beans等查看状态 management: endpoints: - web: - exposure: - include: beans,health + web: + exposure: + include: beans,health spring: mobile: sitepreference: @@ -16,42 +16,46 @@ spring: max-request-size: 100MB # 一次请求总大小上限 ##数据库设置 datasource: - dynamic: - datasource: - master: - username: root - password: root - url: jdbc:mysql://127.0.0.1:3306/depository?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8 - driver-class-name: com.mysql.cj.jdbc.Driver - type: com.alibaba.druid.pool.DruidDataSource - initialSize: 5 - minIdle: 5 - maxActive: 10 - maxWait: 60000 - timeBetweenEvictionRunsMillis: 60000 - minEvictableIdleTimeMillis: 300000 - validationQuery: SELECT 1 FROM DUAL - useGlobalDataSourceStat: true - server: - port: 9090 - testWhileIdle: true - testOnReturn: false - testOnBorrow: false - poolPreparedStatements: true - maxPoolPreparedStatementPerConnectionSize: 20 - #配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙 - filters: stat, wall, log4j - connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 - #超时回收机制 - removeAbandoned: true - removeAbandonedTimeout: 1800 - logAbandoned: true - hr_new: - username: hr_new - password: AnknKiXiXaxNrw78 - url: jdbc:mysql://172.20.2.87:3306/hr_new?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8 - driver-class-name: com.mysql.cj.jdbc.Driver - type: com.alibaba.druid.pool.DruidDataSource + dynamic: + strict: false + primary: master # 配置默认数据库 + datasource: + master: + username: root # 用户名 + password: root #密码 + url: jdbc:mysql://127.0.0.1:3306/depository?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8 + driver-class-name: com.mysql.cj.jdbc.Driver #驱动 + type: com.alibaba.druid.pool.DruidDataSource + + hr_new: + username: hr_new + password: AnknKiXiXaxNrw78 + url: jdbc:mysql://172.20.2.87:3306/hr_new?serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf8 + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.alibaba.druid.pool.DruidDataSource + druid: + initialSize: 5 # 初始连接数 + minIdle: 5 # 最小空闲数 + maxActive: 20 #最大活跃连接数 + maxWait: 60000 #获取连接的最大等待时间(毫秒) + timeBetweenEvictionRunsMillis: 60000 #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + minEvictableIdleTimeMillis: 300000 #配置一个连接在池中最小生存的时间,单位是毫秒 + useGlobalDataSourceStat: true + testWhileIdle: true + testOnReturn: false + testOnBorrow: false + poolPreparedStatements: true + maxPoolPreparedStatementPerConnectionSize: 20 + #配置监控统计拦截的filters,去掉后监控界面sql将无法统计,'wall'用于防火墙 + filters: stat, wall, log4j + connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000 + #超时回收机制 + removeAbandoned: true + removeAbandonedTimeout: 1800 + logAbandoned: true + + + banner: location: banner.txt @@ -78,20 +82,12 @@ spring: max-active: 200 timeout: 2000ms - redisPool: port: 6379 host: 127.0.0.1 dbs: 5,14,15 password: -server: -mybatis: - type-aliases-package: com.dreamchaser.depository_manage.entity - configuration: - log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl - log-prefix: mapper. - mybatis-plus: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl