spring boot 不同的环境使用不同的配置
来源:互联网 发布:泰语翻译中文软件 编辑:程序博客网 时间:2024/06/04 19:45
spring boot中,可以通过在application.yml配置文件中,配置多个不同的profile,实现在不同的环境(比如开发、测试和生产环境)使用不同的配置变量。
具体配置如下(application.yml中的内容):
server: port: 8082# 默认的profile为dev,其他环境通过指定启动参数使用不同的profile,比如:# 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test# 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prodspring: profiles: active: dev---# 开发环境配置spring: profiles: devmysql: ipPort: localhost:3306 ---# 测试环境配置spring: profiles: testmysql: ipPort: 192.168.0.12:8066 ---# 生产环境配置spring: profiles: prodmysql: ipPort: 192.168.0.13:8066
使用方法:
通过指定启动参数使用不同的profile,比如:
# 测试环境:java -jar my-spring-boot.jar --spring.profiles.active=test
# 生产环境:java -jar my-spring-boot.jar --spring.profiles.active=prod
源代码地址:https://github.com/xujijun/my-spring-boot
2 0
- spring boot 不同的环境使用不同的配置
- spring boot 不同的环境使用不同的配置
- Spring-Boot使用profile来配置不同环境的配置文件
- Spring Boot在不同环境的动态配置
- spring profile来用不同的文件,配置不同的环境, deploy不同的war
- spring-boot在不同的环境启动加载不同的配置文件
- spring boot的使用以及环境配置
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- spring使用PropertyPlaceholderConfigurer扩展来满足不同环境的参数配置
- spring boot profiles根据不同环境指定不同配制
- 52. spring boot日志升级篇—log4j多环境不同日志级别的控制【从零开始学Spring Boot】(
- 52. spring boot日志升级篇—log4j多环境不同日志级别的控制【从零开始学Spring Boot】
- 52. spring boot日志升级篇—log4j多环境不同日志级别的控制【从零开始学Spring Boot】
- Spring MVC 根据不同环境加载不同的配置文件
- linux线程调度策略(转)
- python flask中的代码约定
- MATALAB 和 VS联合编程<二>matlab脚本和C#的实现
- HIbernate一级缓存与二级缓存之间的区别
- 杭电ACM1022Train Problem I
- spring boot 不同的环境使用不同的配置
- 底层并发 API
- r文件丢失
- Tomcat的新一代连接池jdbc-pool及实现分析
- WebRTC的优缺点
- redis几种启动方式
- 使用nuget管理c++库的原理
- java IO之文件输入输出流
- git ssh: connect to host gitub.com port 22解决办法