spring boot 配置文件
2017-06-30 17:30
162 查看
1.创建springboot项目 maven配置如下
2.在资源文件下面分别创建三个配置文件(按照自己的项目环境规划 进行创建) 文件名称分别如下application.properties,application-dev.properties,application-prod.properties
2.1 application.properties中的内容
2.2 application-dev.properties中的内容
2.3 application-prod.properties中的内容
3.建立两个类UserProperties和HomeProperties来接受user的属性和home的属性值。主要代码如下
3.1 HomeProperties ,省略get和set方法
3.2 UserProperties如上
4.运行结果
4.1 当spring.profiles.active=dev时 结果如下
4.2 当spring.profiles.active=dev时 结果如下
5.总结
5.1 要注意配置文件的格式 application-xxx.properties ,并且如果配置文件中有中文的话 要设置编码格式并且勾选自动转码
5.2 把公共的配置放到aplication.properties里面 不同环境的配置放到不同的配置文件中
5.3 配置文件类单独放置 方便以后查找
2.在资源文件下面分别创建三个配置文件(按照自己的项目环境规划 进行创建) 文件名称分别如下application.properties,application-dev.properties,application-prod.properties
2.1 application.properties中的内容
2.2 application-dev.properties中的内容
2.3 application-prod.properties中的内容
3.建立两个类UserProperties和HomeProperties来接受user的属性和home的属性值。主要代码如下
3.1 HomeProperties ,省略get和set方法
3.2 UserProperties如上
4.运行结果
4.1 当spring.profiles.active=dev时 结果如下
4.2 当spring.profiles.active=dev时 结果如下
5.总结
5.1 要注意配置文件的格式 application-xxx.properties ,并且如果配置文件中有中文的话 要设置编码格式并且勾选自动转码
5.2 把公共的配置放到aplication.properties里面 不同环境的配置放到不同的配置文件中
5.3 配置文件类单独放置 方便以后查找
相关文章推荐
- 【springboot】Spring boot配置文件 application.properties
- Spring boot 配置文件
- spring boot 读取配置文件(application.yml)中的属性值
- Spring Boot配置文件 application.properties
- spring boot使用profile来区分正式环境配置文件与测试环境配置文件
- Spring boot 通用配置文件模板
- spring boot 读取配置文件
- spring Boot读取配置文件到Map
- Spring Boot属性配置文件详解
- spring boot 使用不同的profile来加载不同的配置文件
- Spring boot配置文件 application.properties
- spring boot 开发,贴一下maven配置文件
- spring boot配置文件
- Spring Boot - 配置文件 application.properties 配置参考
- Spring Boot配置文件乱码的问题
- spring boot 读取配置文件(application.yml)中的属性值
- spring boot 获取配置文件信息
- 错误--spring boot的application.yml配置文件报错
- spring boot加载第三方jar包的配置文件的方法
- Spring Boot配置文件放在jar外部