关于环境的选择问题

来源:2-8 搭建数据库与持久层框架(二)

梁仙森

2022-07-02

这里写的test,是如何判断使用哪个properties文件的?根据文件名称里面包含test名称来决定的吗?
图片描述

写回答

1回答

不知为了什么

2023-05-15

application-{profile}.properties 的格式,其中 {profile} 对应你的环境标识
application.properties:默认配置 application-dev.properties:开发环境 application-test.properties:测试环境 application-prod.properties:生产环境

至于哪个具体的配置文件会被加载,需要在 application.properties 文件中通过 spring.profiles.active 属性来设置,其值对应 {profile} 值。

如:spring.profiles.active=test 就会加载 application-test.properties 配置文件内容


0
0

SpringBoot 2.x 实战仿B站高性能后端项目

还原高性能项目开发全流程,掌握视频业务核心功能与技术

755 学习 · 190 问题

查看课程