yml多环境配置
配置独立各自的环境
注:如果需要修改环境测试,只需要修改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多环境配置的更多相关文章
- 5 — springboot中的yml多环境配置
1.改文件后缀 2.一张截图搞定多环境编写和切换
- springboot 多环境配置yml或properties
https://www.cnblogs.com/mr-yang-localhost/p/8971327.html springboot 多环境配置 https://blog.csdn.net/li ...
- SpringBoot01 InteliJ IDEA安装、Maven配置、创建SpringBoot项目、yml属性配置、多环境配置、自定义properties配置
1 IntelliJ IDEA 安装 下载地址:点击前往 注意:需要下载专业版本的,注册码在网上随便搜一个就行啦 2 MAVEN工具的安装 2.1 获取安装包 下载地址:点击前往 2.2 安装过程 到 ...
- 【Spring Boot学习之七】自定义参数&多环境配置&修改端口号&yml
环境 eclipse 4.7 jdk 1.8 Spring Boot 1.5.2 一.自定义参数通过注解直接获取配置文件application.properties中配置key的value1.appl ...
- OpenCv的Java,C++开发环境配置
1.OpenCV 下载及安装配置 opencv的下载地址:http://opencv.org/downloads.html 最新版本:opencv3.0.0 注意:支持的visual studio20 ...
- SpringBoot01 InteliJ IDEA安装、Maven配置、创建SpringBoot项目、属性配置、多环境配置
1 InteliJ IDEA 安装 下载地址:点击前往 注意:需要下载专业版本的,注册码在网上随便搜一个就行啦 2 MAVEN工具的安装 2.1 获取安装包 下载地址:点击前往 2.2 安装过程 到官 ...
- SpringBoot2.0之六 多环境配置
开发过程中面对不同的环境,例如数据库.redis服务器等的不同,可能会面临一直需要修改配置的麻烦中,在以前的项目中,曾通过Tomcat的配置来实现,有的项目甚至需要手动修改相关配置,这种方式费时费力, ...
- Spring boot项目maven的profile多环境配置不自动替换变量的问题解决
Spring boot项目maven的profile多环境配置不自动替换变量的问题解决 在网上找了好久,配置都很简单,可是我的程序就是不能自动替换变量,最终单独测试,发现原来是引用spring b ...
- Spring Cloud:多环境配置、eureka 安全认证、容器宿主机IP注册
记录一下搭建 Spring Cloud 过程中踩过的一些坑,测试的东西断断续续已经弄了好多了,一直没有时间整理搭建过程,时间啊~时间~ Spring 版本 Spring Boot:2.0.6.RELE ...
随机推荐
- LeetCode9 回文数
题目链接:https://leetcode-cn.com/problems/palindrome-number/ 判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数 ...
- 宝塔安装swoole
新建文件夹 mkdir swoole 切入到文件夹中,进行下载安装包 wget http://pecl.php.net/get/swoole-4.3.2.tgz 解压 tar -zxvf swoole ...
- console.log在IE浏览器中会有异常
因为在IE浏览器无此方法,故此重写 方法一: var console = console || { log: function () { return false; } }; 方法二:window.c ...
- 51nod 1009 数字1的数量(数位dp模板)
给定一个十进制正整数N,写下从1开始,到N的所有正数,计算出其中出现所有1的个数. 例如:n = 12,包含了5个1.1,10,12共包含3个1,11包含2个1,总共5个1. 数位dp的模板题 ...
- php 把数组保存为标准的数组格式,存储到文件中
<?php $file='./test.php'; $array=array('color'=> array('blue','red','green'),'size'=> array ...
- kali-通过获取路由器pin码套取无线网络密码shell脚本
直接上脚本吧, 我做个笔记. #************************************************************************* # > Fil ...
- ArrayList迭代器源码分析
集合的遍历 Java集合框架中容器有很多种类,如下图中: 对于有索引的List集合可以通过for循环遍历集合: List<String> list = new ArrayList<& ...
- 从零开始 CentOs 7 搭建论坛BBS Discuz_X3.2
由于公司项目需要一个互动平台,可以发起活动,发消息留言,讨论过后发现这竟然是一个论坛的功能. 于是就不打算耗费功夫开发相关功能,直接另外搭一套BBS算球... 一直觉得搭建BBS不是一件难事,目前有很 ...
- wireshark基础学习—第二部分wireshark的基础操作
抓取报文: 下载和安装好Wireshark之后,启动Wireshark并且在接口列表中选择接口名,然后开始在此接口上抓包.例如,如果想要在无线网络上抓取流量,点击无线接口.点击Capture Opti ...
- hadoop配置项笔记 - hdfs
hadoop版本:3.1.1 core-site.xml dfs.namenode.rpc-address 作用:rpc地址.我在使用distcp时显式使用到了. 默认值:port是8020 我的设置 ...