Ver código fonte

模块化 配置文件

Gaokun Wang 1 mês atrás
pai
commit
5f0a1b38ec

+ 43 - 0
config/local/datasource-mysql.yml

@@ -0,0 +1,43 @@
+--- # 数据源配置
+spring:
+  datasource:
+    type: com.zaxxer.hikari.HikariDataSource
+mybatis-flex:
+  # sql审计
+  audit_enable: false
+  # sql打印
+  sql_print: true
+  # 数据源
+  datasource:
+    # 数据源1
+    ds1:
+      type: ${spring.datasource.type}
+      # MySql
+      driver-class-name: com.mysql.cj.jdbc.Driver
+      url: jdbc:mysql://localhost:3306/eco-boot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
+      username: root
+      password: root123
+      #DM8数据库
+      #      driver-class-name: dm.jdbc.driver.DmDriver
+      #      url: jdbc:dm://127.0.0.1:5236?schema=eco-boot&useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
+      #      username: SYSDBA
+      #      password: SYSdba123
+      # 最大连接池数量
+      maximum-pool-size: 20
+      # 最小空闲线程数量
+      minimum-idle: 10
+      # 配置获取连接等待超时的时间
+      connectionTimeout: 60000
+      # 校验超时时间
+      validationTimeout: 5000
+      # 空闲连接存活最大时间,默认10分钟
+      idleTimeout: 600000
+      # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
+      maxLifetime: 1800000
+      # 多久检查一次连接的活性
+      keepaliveTime: 30000
+    # 数据源2
+#    ds2:
+#      url: jdbc:mysql://127.0.0.1:3306/eco1
+#      username: root
+#      password: root123

+ 12 - 0
config/local/easy-trans.yml

@@ -0,0 +1,12 @@
+# easy-trans 配置
+easy-trans:
+  # 字典缓存是否放到redis中 做二级缓存,微服务模式推荐开启
+  dict-use-redis: false
+  # 开启redis支持 微服务模式推荐使用redis
+  is-enable-redis: false
+  # 启用全局翻译(拦截所有responseBody进行自动翻译),如果关闭需要手动调用翻译方法或者方法加注解,具体看文档
+  is-enable-global: true
+  # 启平铺模式(transMap的key平铺到和vo一个级别)
+  is-enable-tile: true
+  # 默认为true 如果前期先单体跑,后期可能改为springcloud微服务,可以先设置为false,后期设置为true,设置为false RPC翻译会走SIMPLE的逻辑
+  is-enable-cloud: false

+ 8 - 0
config/local/logging.yml

@@ -0,0 +1,8 @@
+--- # 日志配置
+logging:
+  level:
+    org.springframework: warn
+    com.zaxxer.hikari.pool.HikariPool: ERROR
+    com.zaxxer.hikari.HikariDataSource: ERROR
+    org.mybatis.spring.mapper: error
+    org.springframework.context.support.PostProcessorRegistrationDelegate: error

+ 39 - 0
config/local/mybatis-flex.yml

@@ -0,0 +1,39 @@
+# MyBatisFlex公共配置
+mybatis-flex:
+  # 搜索指定包别名
+  type-aliases-package: org.eco.vip.**.domain.**
+  # 不支持多包, 如有需要可在注解配置 或 提升扫包等级:com.**.**.mapper
+  mapper-package: org.eco.vip.**.mapper
+  # 配置mapper的扫描,找到所有的mapper.xml映射文件
+  mapper-locations: classpath*:mapper/**/*Mapper.xml
+  configuration:
+    # 自动驼峰命名规则(camel case)映射
+    map_underscore_to_camel_case: true
+    # MyBatis 自动映射策略
+    auto_mapping_behavior: FULL
+    # MyBatis 自动映射时未知列或未知属性处理策
+    # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
+    auto_mapping_unknown_column_behavior: NONE
+    # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
+    # 关闭日志记录 org.apache.ibatis.logging.nologging.NoLoggingImpl
+    # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
+    #log_impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
+    cacheEnabled: true
+  global-config:
+    # 逻辑删除存在0
+    normal-value-of-logic-delete: '0'
+    # 逻辑已删除1
+    deleted-value-of-logic-delete: '1'
+    # 默认的逻辑删除字段
+    logic-delete-column: del_flag
+    # 默认的多租户字段
+    tenant-column: tenant_id
+    # 默认的乐观锁字段
+    version-column: version
+    # 是否控制台打印 MyBatis-Flex 的 LOGO 及版本号
+    print-banner: false
+    # 全局的 ID 生成策略配置:雪花算法:snowFlakeId、独创的 FlexID 算法:flexId、UUIDKeyGenerator:uuid
+    key-config:
+      key-type: Generator
+      value: flexId

+ 21 - 0
config/local/sa-token.yml

@@ -0,0 +1,21 @@
+# Sa-Token配置
+sa-token:
+  # token名称 (同时也是cookie名称)
+  token-name: Authorization
+  # token固定超时 设为七天 (必定过期) 单位: 秒
+  timeout: 604800
+  # 多端不同 token 有效期 可查看 LoginHelper.loginByDevice 方法自定义
+  # token最低活跃时间 (指定时间无操作就过期) 单位: 秒
+  active-timeout: 1800
+  # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
+  is-concurrent: true
+  # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
+  is-share: false
+  # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
+  token-style: uuid
+  # 是否输出操作日志
+  is-log: false
+  # 是否打印log
+  is-print: false
+  # jwt秘钥
+  jwt-secret-key: abcdefghijklmnopqrstuvwxyz

+ 19 - 0
config/local/security.yml

@@ -0,0 +1,19 @@
+# security配置
+security:
+  # 排除路径
+  excludes:
+    # 静态资源
+    - /*.html
+    - /**/*.html
+    - /**/*.css
+    - /**/*.js
+    - /profile/**
+    # 公共路径
+    - /favicon.ico
+    - /error
+    # actuator 监控配置
+    - /actuator
+    - /actuator/**
+    # 其它链接
+    - /auth/login
+    - /**

+ 7 - 43
eco-start/src/main/resources/application-local.yml

@@ -1,43 +1,7 @@
---- # 数据源配置
-spring:
-  datasource:
-    type: com.zaxxer.hikari.HikariDataSource
-mybatis-flex:
-  # sql审计
-  audit_enable: false
-  # sql打印
-  sql_print: true
-  # 数据源
-  datasource:
-    # 数据源1
-    ds1:
-      type: ${spring.datasource.type}
-      # MySql
-      driver-class-name: com.mysql.cj.jdbc.Driver
-      url: jdbc:mysql://localhost:3306/eco-boot?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
-      username: root
-      password: root123
-      #DM8数据库
-#      driver-class-name: dm.jdbc.driver.DmDriver
-#      url: jdbc:dm://127.0.0.1:5236?schema=eco-boot&useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
-#      username: SYSDBA
-#      password: SYSdba123
-      # 最大连接池数量
-      maximum-pool-size: 20
-      # 最小空闲线程数量
-      minimum-idle: 10
-      # 配置获取连接等待超时的时间
-      connectionTimeout: 60000
-      # 校验超时时间
-      validationTimeout: 5000
-      # 空闲连接存活最大时间,默认10分钟
-      idleTimeout: 600000
-      # 此属性控制池中连接的最长生命周期,值0表示无限生命周期,默认30分钟
-      maxLifetime: 1800000
-      # 多久检查一次连接的活性
-      keepaliveTime: 30000
-    # 数据源2
-#    ds2:
-#      url: jdbc:mysql://127.0.0.1:3306/eco1
-#      username: root
-#      password: root123
+--- # 开发环境配置
+server:
+  # 服务器的HTTP端口,默认为8080
+  port: 9040
+  servlet:
+    # 应用的访问路径
+    context-path: /

+ 12 - 113
eco-start/src/main/resources/application.yml

@@ -2,6 +2,8 @@
 eco:
   # 名称
   name: eco-boot
+  # 数据库名称
+  db: mysql
 #  # 版本
 #  version: ${revision}
 #  # 版权年份
@@ -13,6 +15,14 @@ spring:
     name: ${eco.name}
   profiles:
     active: @profiles.active@
+  config:
+    import:
+      - file:config/${spring.profiles.active}/mybatis-flex.yml
+      - file:config/${spring.profiles.active}/sa-token.yml
+      - file:config/${spring.profiles.active}/datasource-${eco.db}.yml
+      - file:config/${spring.profiles.active}/logging.yml
+      - file:config/${spring.profiles.active}/easy-trans.yml
+      - file:config/${spring.profiles.active}/security.yml
   mvc:
     format:
       date-time: yyyy-MM-dd HH:mm:ss
@@ -35,118 +45,7 @@ spring:
     virtual:
       enabled: true
 
-# 开发环境配置
-server:
-  # 服务器的HTTP端口,默认为8080
-  port: 9040
-  servlet:
-    # 应用的访问路径
-    context-path: /
-
-
-# Sa-Token配置
-sa-token:
-  # token名称 (同时也是cookie名称)
-  token-name: Authorization
-  # token固定超时 设为七天 (必定过期) 单位: 秒
-  timeout: 604800
-  # 多端不同 token 有效期 可查看 LoginHelper.loginByDevice 方法自定义
-  # token最低活跃时间 (指定时间无操作就过期) 单位: 秒
-  active-timeout: 1800
-  # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
-  is-concurrent: true
-  # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
-  is-share: false
-  # token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
-  token-style: uuid
-  # 是否输出操作日志
-  is-log: false
-  # 是否打印log
-  is-print: false
-  # jwt秘钥
-  jwt-secret-key: abcdefghijklmnopqrstuvwxyz
-# security配置
-security:
-  # 排除路径
-  excludes:
-    # 静态资源
-    - /*.html
-    - /**/*.html
-    - /**/*.css
-    - /**/*.js
-    - /profile/**
-    # 公共路径
-    - /favicon.ico
-    - /error
-    # actuator 监控配置
-    - /actuator
-    - /actuator/**
-    # 其它链接
-    - /auth/login
-    - /**
-
-# MyBatisFlex公共配置
-mybatis-flex:
-  # 搜索指定包别名
-  type-aliases-package: org.eco.vip.**.domain.**
-  # 不支持多包, 如有需要可在注解配置 或 提升扫包等级:com.**.**.mapper
-  mapper-package: org.eco.vip.**.mapper
-  # 配置mapper的扫描,找到所有的mapper.xml映射文件
-  mapper-locations: classpath*:mapper/**/*Mapper.xml
-  configuration:
-    # 自动驼峰命名规则(camel case)映射
-    map_underscore_to_camel_case: true
-    # MyBatis 自动映射策略
-    auto_mapping_behavior: FULL
-    # MyBatis 自动映射时未知列或未知属性处理策
-    # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息
-    auto_mapping_unknown_column_behavior: NONE
-    # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl
-    # 关闭日志记录 org.apache.ibatis.logging.nologging.NoLoggingImpl
-    # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl
-    #log_impl: org.apache.ibatis.logging.stdout.StdOutImpl
-    logImpl: org.apache.ibatis.logging.nologging.NoLoggingImpl
-    cacheEnabled: true
-  global-config:
-    # 逻辑删除存在0
-    normal-value-of-logic-delete: '0'
-    # 逻辑已删除1
-    deleted-value-of-logic-delete: '1'
-    # 默认的逻辑删除字段
-    logic-delete-column: del_flag
-    # 默认的多租户字段
-    tenant-column: tenant_id
-    # 默认的乐观锁字段
-    version-column: version
-    # 是否控制台打印 MyBatis-Flex 的 LOGO 及版本号
-    print-banner: false
-    # 全局的 ID 生成策略配置:雪花算法:snowFlakeId、独创的 FlexID 算法:flexId、UUIDKeyGenerator:uuid
-    key-config:
-      key-type: Generator
-      value: flexId
-
-
-# easy-trans 配置
-easy-trans:
-  # 字典缓存是否放到redis中 做二级缓存,微服务模式推荐开启
-  dict-use-redis: false
-  # 开启redis支持 微服务模式推荐使用redis
-  is-enable-redis: false
-  # 启用全局翻译(拦截所有responseBody进行自动翻译),如果关闭需要手动调用翻译方法或者方法加注解,具体看文档
-  is-enable-global: true
-  # 启平铺模式(transMap的key平铺到和vo一个级别)
-  is-enable-tile: true
-  # 默认为true 如果前期先单体跑,后期可能改为springcloud微服务,可以先设置为false,后期设置为true,设置为false RPC翻译会走SIMPLE的逻辑
-  is-enable-cloud: false
-
-
-
-# 日志配置
+--- # 日志配置
 logging:
   level:
-    org.eco.vip: @logging.level@
-    org.springframework: warn
-    com.zaxxer.hikari.pool.HikariPool: ERROR
-    com.zaxxer.hikari.HikariDataSource: ERROR
-    org.mybatis.spring.mapper: error
-    org.springframework.context.support.PostProcessorRegistrationDelegate: error
+    org.eco.vip: @logging.level@