当前位置:网站首页>profile环境切换
profile环境切换
2022-07-24 18:58:00 【为什么不好好卖蛋饼】
profile环境切换
1 application_profile功能
高级特性
多环境适配
场景1
微服务多创建几个配置
配置1 application_properties
// 一开始啥也不放
spring.profiles.active=prod
//spring.profiles.active=test
配置2 测试环境 application_test.yaml
person:
name: test-李四
配置3 生产环境 application_prod.yaml
person:
name: prod-王五
server:
port: 8000
如果出现了同名配置
激活了谁,就用谁的。
server:
port: 8080
spring.profiles.active=prod
命令行执行
java -jar jar包名 --spring.profiles.active=test
命令行激活,修改配置文件的任意值,命令行优先。
java -jar jar包名 --spring.profiles.active=test --person.name=haha
2 用于条件装配
生产环境
server:
port: 8080
spring.profiles.active=prod
新建接口Person
public interface Person {
String getName();
Integer getAge();
}
新建两个子类
生产环境boss
@Profile("prod")
@Data
@ConfigurationProperties("person")
@Component
public class Boss implements Person{
private String name;
private Integer age;
}
测试环境worker
@Profile("test")
@Data
@ConfigurationProperties("person")
@Component
public class Worker implements Person{
private String name;
private Integer age;
}
controller
@Autowired
private Person person;
@Value("${person.name:李四}")
public String name;
@GetMapping("/")
public String hello(){
return person.getClass().toString();
}
3 profile分组
麻了,等我厉害点再来/
边栏推荐
- New stage of investment
- 2022 Hangdian multi school second session 1009 shuangq (Mathematics)
- 今日睡眠质量记录79分
- Converter
- 全国职业院校技能大赛网络安全竞赛——Apache安全配置详解
- Analysis of several possible causes of 0xc0000005 memory violation
- 网络安全80端口—-PHP CGI参数注入执行漏洞
- Principle and application of database
- Sequences, time series and prediction in tessorflow quizs on coursera (I)
- 2022杭电多校第一场Dragon slayer(dfs+状态压缩)
猜你喜欢

Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag

Valentine's Day gift ----- use her photos and our chat records to generate word clouds~

MySQL - bufferpool related information

Vsftpd2.3.4-端口渗透 6200 irc_3281_backdoor

Mysqlworkbench performance analysis tool -- Performance dashboard

网络安全80端口—-PHP CGI参数注入执行漏洞

Nftscan and port3 have reached strategic cooperation in the field of NFT data

2022杭电多校第二场1009 ShuanQ(数学)

Common problems of multithreading and concurrent programming (to be continued)

理解动态计算图,requires_grad、zero_grad
随机推荐
Reading notes of XXL job source code
Unity框架之ConfigManager【Json配置文件读写】
Sqoop
Ionic4 learning notes 5-- custom public module
第4章 复合类型
Analysis of dropout principle in deep learning
FPGA 20 routines: 9. DDR3 memory particle initialization write and read through RS232 (Part 1)
Vsftpd2.3.4-端口渗透 6200 irc_3281_backdoor
OpenGL learning (V) modern OpenGL triangle rendering
Go Xiaobai implements a simple go mock server
redis 数据类型
Ionic4 learning notes 13 - Classification List of an East Project
JDBC batch inserts 100000 /1million pieces of data
OPENGL学习(四)GLUT三维图像绘制
FPGA 20 routines: 9. DDR3 memory particle initialization write and read through RS232 (Part 2)
Understand dynamic calculation diagram, requires_ grad、zero_ grad
Mysql数据库,去重,连接篇
DDR SDRAM board design guide
2022 Hangzhou Electric Multi school first Dragon Slayer (dfs+ state compression)
[Tkinter] common components (II)