1、多环境配置

1、先在resources资源下创建bootstrap.yml

server:
  tomcat:
    uri-encoding: utf-8
    max-threads: 1000
    min-spare-threads: 30
  port: 8185
  connection-timeout: 50000ms
spring:
  application:
    name: pd-base
  profiles:
    active: dev
  main:
    allow-bean-definition-overriding: true

2、同层级增加bootstrap-dev.yml

spring:
  cloud:
    nacos:
      username: nacos
      password: nacos
      discovery:
        server-addr: 43.143.151.90:8848
        group: pinda-tms
        namespace: b9264769-754f-45f7-8900-f8ae48415d96
      config:
        server-addr: 43.143.151.90:8848
        file-extension: yml
        group: pinda-tms
        namespace: b9264769-754f-45f7-8900-f8ae48415d96

  # jackson时间格式化
  jackson:
    time-zone: ${spring.jackson.time-zone}
    date-format: ${spring.jackson.date-format}
  servlet:
    multipart:
      max-file-size: ${spring.servlet.multipart.max-file-size}
      max-request-size: ${spring.servlet.multipart.max-request-size}
      enabled: ${spring.servlet.multipart.enabled}

  datasource:
    druid:
      type: ${spring.datasource.druid.type}
      driver-class-name: ${spring.datasource.druid.driver-class-name}
      url: ${spring.datasource.druid.url}
      username: ${spring.datasource.druid.username}
      password: ${spring.datasource.druid.password}
      initial-size: ${spring.datasource.druid.initial-size}
      max-active: ${spring.datasource.druid.max-active}
      min-idle: ${spring.datasource.druid.min-idle}
      max-wait: ${spring.datasource.druid.max-wait}
      pool-prepared-statements: ${spring.datasource.druid.pool-prepared-statements}
      max-pool-prepared-statement-per-connection-size: ${spring.datasource.druid.max-pool-prepared-statement-per-connection-size}
      time-between-eviction-runs-millis: ${spring.datasource.druid.time-between-eviction-runs-millis}
      min-evictable-idle-time-millis: ${spring.datasource.druid.min-evictable-idle-time-millis}
      test-while-idle: ${spring.datasource.druid.test-while-idle}
      test-on-borrow: ${spring.datasource.druid.test-on-borrow}
      test-on-return: ${spring.datasource.druid.test-on-return}
      stat-view-servlet:
        enabled: ${spring.datasource.druid.stat-view-servlet.stat-view-servlet}
        url-pattern: ${spring.datasource.druid.stat-view-servlet.url-pattern}
      filter:
        stat:
          log-slow-sql: ${spring.datasource.druid.filter.stat.log-slow-sql}
          slow-sql-millis: ${spring.datasource.druid.filter.stat.slow-sql-millis}
          merge-sql: ${spring.datasource.druid.filter.stat.merge-sql}
        wall:
          config:
            multi-statement-allow: ${spring.datasource.druid.filter.wall.config.multi-statement-allow}
#mybatis
mybatis-plus:
  mapper-locations: ${mybatis-plus.mapper-locations}
  #实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: ${mybatis-plus.typeAliasesPackage}
  global-config:
    #数据库相关配置
    db-config:
      #主键类型  AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
      id-type: ${mybatis-plus.global-config.db-config.id-type}
      #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
      field-strategy: ${mybatis-plus.global-config.db-config.field-strategy}
      #驼峰下划线转换
      column-underline: ${mybatis-plus.global-config.db-config.column-underline}
      logic-delete-value: ${mybatis-plus.global-config.db-config.logic-delete-value}
      logic-not-delete-value: ${mybatis-plus.global-config.db-config.logic-not-delete-value}
    banner: ${mybatis-plus.global-config.banner}

  #原生配置
  configuration:
    map-underscore-to-camel-case: ${mybatis-plus.configuration.map-underscore-to-camel-case}
    cache-enabled: ${mybatis-plus.configuration.cache-enabled}
    call-setters-on-nulls: ${mybatis-plus.configuration.call-setters-on-nulls}
    jdbc-type-for-null: ${mybatis-plus.configuration.jdbc-type-for-null}
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

3、Nacos中配置

spring:
    # jackson时间格式化
  jackson:
    time-zone: GMT+8
    date-format: yyyy-MM-dd HH:mm:ss
  servlet:
    multipart:
      max-file-size: 100MB
      max-request-size: 100MB
      enabled: true
  
  datasource:
      type: com.alibaba.druid.pool.DruidDataSource
      druid:
          driver-class-name: com.mysql.jdbc.Driver
          url: jdbc:mysql://43.143.151.90:3306/pd_base?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull
          username: root
          password: Wsh@9210832

          initial-size: 10
          max-active: 100
          min-idle: 10
          max-wait: 60000
          pool-prepared-statements: true
          max-pool-prepared-statement-per-connection-size: 20
          time-between-eviction-runs-millis: 60000
          min-evictable-idle-time-millis: 300000
          test-while-idle: true
          test-on-borrow: false
          test-on-return: false
          stat-view-servlet:
              enabled: true
              url-pattern: /druid/*
          filter:
              stat:
                  log-slow-sql: true
                  slow-sql-millis: 1000
                  merge-sql: false
              wall:
                  config:
                      multi-statement-allow: true
#mybatis
mybatis-plus:
  mapper-locations: classpath*:/mapper/*/*.xml
  #实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: com.itheima.pinda.entity.*
  global-config:
    #数据库相关配置
    db-config:
      #主键类型  AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
      id-type: AUTO
      #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
      field-strategy: NOT_NULL
      #驼峰下划线转换
      column-underline: true
      logic-delete-value: -1
      logic-not-delete-value: 0
    banner: false
  #原生配置
  configuration:
    map-underscore-to-camel-case: true
    cache-enabled: false
    call-setters-on-nulls: true
    jdbc-type-for-null: 'null'