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

  • 相关阅读:
    基于Adaboost的人脸检测算法
    操作系统笔试题及答案
    eclipse Maven plugin 配置
    网站服务管理系统系列教程之五
    2017第4周日
    2017春节~人生智慧箴言
    2017年初夕
    2017农历二十九
    王国维收藏真伪
    2017第3周二假期里该做的事
  • 原文地址:https://www.cnblogs.com/mingforyou/p/15553081.html
Copyright © 2011-2022 走看看