多环境配置

多环境配置

  • 导包
<build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <!-- 处理文件时替换文件中的变量 -->
                <filtering>true</filtering>
                <excludes>
                    <!-- 打包时排除文件 -->
                    <exclude>application.yml</exclude>
                    <exclude>application-hp.yml</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <!-- 打包时所包含得文件 -->
                <includes>
                    <include>application.yml</include>              				
                    <include>application-${profileActive}.yml</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!--                // 指定版本和goals-->
                <!--suppress UnresolvedMavenProperty -->
                <version>2.2.2.RELEASE</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>dev</id>
            <properties>
                <profileActive>dev</profileActive>
            </properties>
        </profile>
        <profile>
            <id>test</id>
            <properties>
                <profileActive>test</profileActive>
            </properties>
        </profile>
        <profile>
            <id>pack</id>
            <properties>
                <profileActive>pack</profileActive>
            </properties>
        </profile>
    </profiles>
  • 配置文件application.yml

    spring:
      jackson:
        date-format: yyyy-MM-dd HH:mm:ss
        time-zone: GMT+8
      profiles:
        active: @profileActive@
    
    • 开发环境 application-dev.yml

      server:
        port: 1030
      
      spring:
        application:
          name: charge-server
        main:
          allow-bean-definition-overriding: true
        cloud:
          nacos:
            discovery:
              server-addr: 	#注册中心地址
              group: DEFAULT_GROUP
        datasource:
          url: 
          username: 
          password: 
          driver-class-name: com.mysql.cj.jdbc.Driver
        redis:
          # Redis数据库索引(默认为0)
          database: 0
          # Redis服务器地址
          host:
          # Redis服务器连接端口
          port: 
          # Redis服务器连接密码(默认为空)
          password:
          jedis:
            pool:
              #连接池最大连接数(使用负值表示没有限制)
              max-active: 8
              # 连接池最大阻塞等待时间(使用负值表示没有限制)
              max-wait: -1
              # 连接池中的最大空闲连接
              max-idle: 8
              # 连接池中的最小空闲连接
              min-idle: 0
              # 连接超时时间(毫秒)
              timeout: 10000
      management:
        health:
          redis:
            enabled: false #关闭redis健康检查
          sentinel:
            enabled: false #关闭sentinel健康检查
          ldap:
            enabled: false #关闭ldap健康检查
        endpoints:
          web:
            exposure:
              include: '*'
          health:
            sensitive: false #关闭过滤敏感信息
        endpoint:
          health:
            show-details: ALWAYS  #显示详细信息
      mybatis-plus:
      #  type-aliases-package: es.financeReport.domain
        mapper-locations: classpath*:/mapper/*Mapper.xml,/api/mapper/*Mapper.xml
        type-aliases-package: api.entity
        global-config:
          # 关闭MP3.0自带的banner
          banner: false
          db-config:
            #主键类型  0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
            id-type: 4
            # 默认数据库表下划线命名
            table-underline: true
          configuration:
            # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
            log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
            # 返回类型为Map,显示null对应的字段
            call-setters-on-nulls: true
      # 日志配置
      # 暂时DEV环境配置日志等级为DEBUG级别 方便排查SQL入参
      # todo 其他环境日志等级默认配置
      logging:
        config: classpath:logback-spring.xml
        level:
            com.es.charge.mapper.* : debug
      #易软公司账号
      defaultNumber: yrgs
      # 自定义线程池配置
      thread-pool.name: charge-threads-async
      thread-pool.core-size: 4
      thread-pool.max-size: 10
      thread-pool.alive-time: 60000
      thread-pool.queue-size: 200
      
      

harge-threads-async
thread-pool.core-size: 4
thread-pool.max-size: 10
thread-pool.alive-time: 60000
thread-pool.queue-size: 200

```
  • 如图在这里插入图片描述
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值