Spring boot Sample 005之spring-boot-profile
一、环境
1.1、Idea 2020.1
1.2、JDK 1.8
二、目的
三、步骤
3.1、点击File -> New Project -> Spring Initializer,点击next

3.2、在对应地方修改自己的项目信息

3.3、选择Web依赖,选中Spring Web。可以选择Spring Boot版本,本次默认为2.2.6,点击Next

3.4、编辑工程名和项目路径,确定后点击Finish完成

3.5、项目结构

四、添加测试文件

package org.ouyushan.springboot.profile; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment; @SpringBootApplication
public class SpringBootProfileApplication { public static void main(String[] args) {
ConfigurableApplicationContext applicationContext = SpringApplication.run(SpringBootProfileApplication.class, args);
ConfigurableEnvironment environment = applicationContext.getEnvironment();
System.out.println("server.port:" + environment.getProperty("server.port"));
} }
4.1、配置默认application.yaml
spring:
profiles:
active: dat
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: Asia/Chongqing
4.2、配置application-dat.yaml:
server:
port: 7070
4.3、配置application-uat.yaml:
server:
port: 8080
4.4、配置application-vir.yaml:
server:
port: 9090

五、知识点
一般将公共属性配置在application.yaml中,与环境相关的属性配置在对应的配置中,只需在application.yaml中配置
spring:
profiles:
active: uat
Spring boot Sample 005之spring-boot-profile的更多相关文章
- Spring boot Sample 012之spring-boot-web-upload
一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 spring boot 整合web实现文件上传下载 三.步骤 3.1.点击File -> New Project -& ...
- Spring boot Sample 0010之spring-boot-web-freemarker
一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 spring boot 整合freemarker模板开发web项目 三.步骤 3.1.点击File -> New Pr ...
- Spring boot Sample 009之spring-boot-web-thymeleaf
一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.目的 spring boot 整合thymeleaf模板开发web项目 三.步骤 3.1.点击File -> New Pro ...
- Spring boot Sample 006之spring-boot-custom-servlet
一.环境 1.1.Idea 2020.1 1.2.JDK 1.8 二.步骤 2.1.点击File -> New Project -> Spring Initializer,点击next 2 ...
- Spring Boot (五)Spring Data JPA 操作 MySQL 8
一.Spring Data JPA 介绍 JPA(Java Persistence API)Java持久化API,是 Java 持久化的标准规范,Hibernate是持久化规范的技术实现,而Sprin ...
- 初入spring boot(七 )Spring Data JPA
Spring Data JPA通过提供基于JPA的Repository极大地减少JPA作为数据访问方案的代码量. 1.定义数据访问层 使用Spring Data JPA建立数据访问层十分简单,只需定义 ...
- Spring Boot配置篇(基于Spring Boot 2.0系列)
1:概述 SpringBoot支持外部化配置,配置文件格式如下所示: properties files yaml files environment variables command-line ar ...
- Spring 5.x 、Spring Boot 2.x 、Spring Cloud 与常用技术栈整合
项目 GitHub 地址:https://github.com/heibaiying/spring-samples-for-all 版本说明: Spring: 5.1.3.RELEASE Spring ...
- Spring Boot-初学01 -使用Spring Initializer快速创建Spring Boot项目 -@RestController+spEL -实现简单SpringBoot的Web页面
1.IDEA:使用 Spring Initializer快速创建项目 IDE都支持使用Spring的项目创建向导快速创建一个Spring Boot项目: 选择我们需要的模块:向导会联网创建Spring ...
随机推荐
- A. Hilbert's Hotel(数学)
传送门 \(看了一下网上都没什么题解,自己写一篇吧,对你有帮助的话留个言吧~\) \(\color{Orange}{----------------------分割------------------ ...
- 前缀和(P2697 宝石串)
前言 每次做出来什么本来做不出的题目,就忍不住记录一下.不过大多时候隔几天来看,就发现,啊,我当时只是做了一道这么弱智的题目呀,哈哈.前缀和确实不算太难.. 传送门 题目大意: 给你一个字符串只含G和 ...
- Linux查看redis占用内存的方法
redis-cli auth 密码info # Memory used_memory:13490096 //数据占用了多少内存(字节) used_memory_human:12.87M //数据占用了 ...
- 选择结构(if、switch)
3.2 用if语句实现选择结构 什么是选择结构 单分支if语句 双分支if语句 多分支if语句 1.什么是选择结构? 选择结构又称为分支结构,是根据给定的条件是否成立来决定程序的执行流程. 用if语 ...
- 深入理解CSS定位
CSS中有3种定位机制:普通流,浮动和绝对定位.除非专门指定,否则所有框都在普通流中定位.顾名思义,普通流中元素框的位置由HTML元素的位置决定.块级框一个接一个地垂直排列,框之间的垂直距离由框的垂直 ...
- thrift的使用
简介 thrift 原来是facebook的rpc框架,根据数据结构和接口描述生成多种语言的接口,方便使用多种语言进行开发,详细信息这里不再赘述,下文以一个简单的代码(C++)示例来介绍使用方法. 示 ...
- 第一行Kotlin系列(一)kotlin按钮点击事件
按钮findViewBuId <Button android:id="@+id/mButton4" android:layout_width="wrap_conte ...
- Python 简明教程 --- 2,第一个Python 程序
微信公众号:码农充电站pro 个人主页:https://codeshellme.github.io 如果你发现特殊情况太多,那你肯定是用错方法了. -- Carig Zerouni 当你在自己的电脑上 ...
- 微信小程序开发实战(1):使用滚动视图
本文主要介绍了滚动视图组件(scroll-view)的各种常用功能,例如,垂直和水平滚动.滚动事件等,并通过例子代码来演示这些功能的使用方法. 1. 垂直滚动视图 scroll-view是容器组件 ...
- python--遇到SyntaxError: Non-UTF-8 code starting with '\xb8' in file
在运行python中因为添加了中文注释,遇到SyntaxError: Non-UTF-8 code starting with '\xb8' in file 经过百度,说是Python的默认编码格式是 ...