配置独立各自的环境

注:如果需要修改环境测试,只需要修改spring: profiles: active: “环境名”

spring:
profiles:
active: prd ---
#开发环境配置-------------------------
server:
port: 8081 spring:
profiles: dev
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/kyx?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root
#------------------ ---
#测试环境配置
server:
port: 8082 spring:
profiles: test
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/kyx?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root
#------------------ ---
#生产环境
server:
port: 8083 spring:
profiles: prd
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/kyx?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root #------------------ mybatis:
config-location: classpath:/static/mybatis-config.xml
mapper-locations: classpath:/mappers/*.xml
type-aliases-package: com.example.demo.model

pom依赖

<profiles>
<!--开发环境-->
<profile>
<id>dev</id>
<properties>
<build.profile.id>dev</build.profile.id>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!--测试环境-->
<profile>
<id>test</id>
<properties>
<build.profile.id>test</build.profile.id>
</properties>
</profile>
<!--生产环境-->
<profile>
<id>prd</id>
<properties>
<build.profile.id>prd</build.profile.id>
</properties>
</profile>
</profiles>

配置统一端口

spring:
profiles:
active: prd server:
port: 8081
---
#开发环境配置------------------------- spring:
profiles: dev
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/kyx?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root
#------------------ ---
#测试环境配置 spring:
profiles: test
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/kyx?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root
#------------------ ---
#生产环境 spring:
profiles: prd
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/kyx?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root #------------------ mybatis:
config-location: classpath:/static/mybatis-config.xml
mapper-locations: classpath:/mappers/*.xml
type-aliases-package: com.example.demo.model

yml多环境配置的更多相关文章

  1. 5 — springboot中的yml多环境配置

    1.改文件后缀 2.一张截图搞定多环境编写和切换

  2. springboot 多环境配置yml或properties

    https://www.cnblogs.com/mr-yang-localhost/p/8971327.html   springboot 多环境配置 https://blog.csdn.net/li ...

  3. SpringBoot01 InteliJ IDEA安装、Maven配置、创建SpringBoot项目、yml属性配置、多环境配置、自定义properties配置

    1 IntelliJ IDEA 安装 下载地址:点击前往 注意:需要下载专业版本的,注册码在网上随便搜一个就行啦 2 MAVEN工具的安装 2.1 获取安装包 下载地址:点击前往 2.2 安装过程 到 ...

  4. 【Spring Boot学习之七】自定义参数&多环境配置&修改端口号&yml

    环境 eclipse 4.7 jdk 1.8 Spring Boot 1.5.2 一.自定义参数通过注解直接获取配置文件application.properties中配置key的value1.appl ...

  5. OpenCv的Java,C++开发环境配置

    1.OpenCV 下载及安装配置 opencv的下载地址:http://opencv.org/downloads.html 最新版本:opencv3.0.0 注意:支持的visual studio20 ...

  6. SpringBoot01 InteliJ IDEA安装、Maven配置、创建SpringBoot项目、属性配置、多环境配置

    1 InteliJ IDEA 安装 下载地址:点击前往 注意:需要下载专业版本的,注册码在网上随便搜一个就行啦 2 MAVEN工具的安装 2.1 获取安装包 下载地址:点击前往 2.2 安装过程 到官 ...

  7. SpringBoot2.0之六 多环境配置

    开发过程中面对不同的环境,例如数据库.redis服务器等的不同,可能会面临一直需要修改配置的麻烦中,在以前的项目中,曾通过Tomcat的配置来实现,有的项目甚至需要手动修改相关配置,这种方式费时费力, ...

  8. Spring boot项目maven的profile多环境配置不自动替换变量的问题解决

    Spring boot项目maven的profile多环境配置不自动替换变量的问题解决   在网上找了好久,配置都很简单,可是我的程序就是不能自动替换变量,最终单独测试,发现原来是引用spring b ...

  9. Spring Cloud:多环境配置、eureka 安全认证、容器宿主机IP注册

    记录一下搭建 Spring Cloud 过程中踩过的一些坑,测试的东西断断续续已经弄了好多了,一直没有时间整理搭建过程,时间啊~时间~ Spring 版本 Spring Boot:2.0.6.RELE ...

随机推荐

  1. java串口通信丢包

    java串口通信丢包问题 前段时间公司要求做一个java应用和pos串口通信的工具,调试好了好久每次都是只能接收到一包数据后续的数据都丢失了. 经过修改读写的流的缓存大小亲测都正常代码如下: seri ...

  2. java线程学习之yield方法

    yield方法是暂停当前正在执行的线程对象,并执行其他线程. 这是一个静态方法,一旦执行,它会使当前线程让出CPU.让出的cpu并不代表当前线程不执行了.当前线程让出CPU后,还会CPU资源的争夺,但 ...

  3. 第一章 Python程序语言简介

    第一节 Python概述 1. 什么是Python Python是一种 解释型.面向对象.动态数据类型 的高级程序设计语言.由Guido van Rossum与1989年发明,第一个公开发行版本发行于 ...

  4. Event and Delegate

    文章著作权归作者所有.转载请联系作者,并在文中注明出处,给出原文链接. 本文原更新于作者的github博客,这里给出链接. 委托 委托的实质是一个类. // 委托定义 delegate ReturnT ...

  5. 常用的tcpdump操作

    tcpdump -i eth0 icmp and host 192.168.0.111 -nn -tttt 用ping检测网络情况时抓包,-nn 显示ip和端口而不是机器名和进程名,-tttt 显示详 ...

  6. python第二天3.1

    算数运算符arithmetic operator: + - * / % % : 取余,取模.取的是第一个操作数和第二个操作数除法的余数.整除结果为0. 10 % 3              1 10 ...

  7. 单体 VS 微服务

    看图说话 群里发来一张图, 形象TM又生动: 异同之处 借此对比说说单体和微服务的异同之处: 一大坨的时候, 难泄, 具体表现为, 牵一发而动全身, 时而久之, 便秘/肠道不适/影响代谢/肤色变差/身 ...

  8. 为git关联编辑器(比如notepad++) Associating text editors with Git

    Associating text editors with git Using Notepad++ as your editors you can set your default editor in ...

  9. 为 pip install 设置 socks5 代理

    参考 How to use pip with socks proxy? 为 pip install 设置 socks5 代理 设置方法: pip install pysocks pip install ...

  10. IOS 模块并且发布到NPM

      注释:导入出错 请使用这个 #import <React/RCTBridge.h>   参考文档:http://www.liuchungui.com/blog/2016/05/02/r ...