spring boot配置文件
来源:互联网 发布:校园网络借贷 编辑:程序博客网 时间:2024/05/17 14:17
1、配置文件
1)application.properties(核心配置文件)
test.a= a_propertiestest.b = b_${test.a}
2)application.yml(核心配置文件)
test: a: a.yml b: b_${test.a} c: c.yml d: d_${test.c}
3)other.properties(普通配置文件)
other.config= this is common config!
4)类中读取属性值
@Value("${test.a}")private String a;
@Value("${test.b}")private String b;@Value("${test.c}")private String c;@Value("${test.d}")private String d;private static String other;static { ResourceBundle oBundle = ResourceBundle.getBundle("other"); other = oBundle.getString("other.config");}@GetMapping("/test")public String testConfig() { return a + " ; " + b + " ; " + c + " ; " + d + " ; " + other;}
注:application.properties与application.yml都会自动加载,相同配置优先使用application.properties中设置的值
2、切换配置文件
1)默认配置:application.yml
config: description: This is default config!# 配置文件切换#spring:# profiles:# active: test
2)测试环境配置:application-test.yml
config: description: This is test config!
3)生产环境配置:application-prod.yml
config: description: This is produce config!
3、设置context-path和端口号
#设置context-path和端口号,默认为"/"和8080server: context-path: /v port: 18080
阅读全文
0 0
- spring-boot配置文件
- Spring Boot 配置文件模板
- Spring Boot属性配置文件
- spring boot 工程配置文件
- Spring boot 配置文件
- Spring boot读取配置文件
- spring boot配置文件
- spring boot (二) 配置文件
- spring-boot 配置文件
- spring Boot 配置文件详解
- Spring Boot之配置文件
- spring-boot 配置文件读取
- Spring Boot 配置文件介绍
- Spring boot 配置文件读取
- spring boot配置文件
- spring boot 读取配置文件
- spring boot 配置文件详解
- Spring Boot配置文件详解
- MySQL-索引03
- Android 项目中使用调用jni库调用本地C/C++方法
- 宏定义中的 # , ##以及 _ _VA_ARGS_ _ 的作用
- 微信公众平台自带的生成公众号二维码的连接
- leetcode41. First Missing Positive
- spring boot配置文件
- oracle数据库启动listen报错
- Java的JAR文件入门篇
- lass使用方法
- macbook 远程操作linux后台
- ArrayList底层几个注意的点
- DeepLearning(基于caffe)实战项目(10)--Python编写网络配置文件
- Java面向对象的理解
- map、set、for(x:y)、auto