zoukankan      html  css  js  c++  java
  • SpringBoot配置不同环境的yml配置文件

    <!-- mysql驱动 -->
            <dependency>
                <groupId>mysql</groupId>
                <artifactId>mysql-connector-java</artifactId>
                <version>8.0.20</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>druid-spring-boot-starter</artifactId>
                <version>1.2.5</version>
            </dependency>

    application.yml 配置共同的参数,并确定当前运行环境

    spring:
      profiles:
        active: dev

    这里的spring.profiles.active=dev即表示,当前是dev环境;application-{profile}.yml就对应application-dev.yml,{profile}的取值可以是dev, test, rc, pro

    application-dev.yml

    server:
      port: 8050
    
    ############################################################
    #
    # 配置数据源信息
    #
    ############################################################
    spring:
      profiles: dev
      datasource:                                           # 数据源的相关配置
        name: dev
        type: com.alibaba.druid.pool.DruidDataSource        # 使用druid数据源
        driver-class-name: com.mysql.cj.jdbc.Driver          # mysql驱动
        url: jdbc:mysql://127.0.0.1:3406/my_hbl?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8&useAffectedRows=true&useAffectedRows=true
        username: root
        password: Root&123456
        filters: stat
        maxActive: 20
        initialSize: 1
        maxWait: 60000
        minIdle: 1
        timeBetweenEvictionRunsMillis: 60000
        minEvictableIdleTimeMillis: 300000
        validationQuery: select &#39;x&#39;
        testWhileIdle: true
        testOnBorrow: false
        testOnReturn: false
        poolPreparedStatements: true
        maxOpenPreparedStatements: 20

  • 相关阅读:
    leecode4:寻找两个正序数组的中位数
    leecode3:无重复字符的最长子串
    leecode2:两数相加
    KMP字符串模式匹配
    01迷宫问题
    汉诺塔问题
    微服务-基于Grpc的进程通信-Grpc异常捕获RpcException(4-4)
    React-Antd Pro增删改查
    HTTP 请求
    创业路上-1
  • 原文地址:https://www.cnblogs.com/mingforyou/p/15553081.html
Copyright © 2011-2022 走看看