SpringBoot项目多环境开发

1.yml文件(旧)

说明:旧的写法。

XML 复制代码
#应用环境
spring:
  profiles:
    active: dev
---
#设置环境


#生产环境
spring:
  profiles: pro
server:
  port: 81

---
#开发环境
spirng:
  profiles: dev
server:
  port: 81


---
#测试环境
spring:
  profiles: test
server:
  port: 82

2.yml文件(新)

说明:以下是最新配置。

XML 复制代码
#应用环境
spring:
  profiles:
    active: test
---
#设置环境


#生产环境
spring:
  config:
    activate:
      on-profile: pro
server:
  port: 81

---
#开发环境
spring:
  config:
    activate:
      on-profile: dev
server:
  port: 81


---
#测试环境
spring:
  config:
    activate:
      on-profile: test
server:
  port: 82

3.文件区别

说明:可以创建不同的文件进行区分开发环境、测试环境、生产环境。在application.yml主文件配置。

XML 复制代码
spring:
  profiles:
    active: test

4.properties文件说明

5. 技巧

相关推荐
ltl10 分钟前
RocksDB Leveled Compaction:层级不变式与 CompactionPicker
数据库
ltl11 分钟前
DuckDB 向量化与 Morsel-Driven Pipeline
数据库
北斗落凡尘19 分钟前
LangGraph 入门实战(12)--使用MCP
后端·python·langchain
NJCloud25 分钟前
TiDB 集群部署与 MySQL 兼容性适配实战
linux·运维·数据库·mysql·tidb
喜欢打篮球的普通人43 分钟前
LLVM Backend Lowering 从入门到实战:把 IR 变成机器码的完整链路
android·java·数据库
jufeng13072 小时前
【系列:TDengine 工业物联网实战:从零搭起可运行系统 · 第 8 篇】
java·spring boot·时序数据库·tdengine
SomeB1oody2 小时前
【RustyML入门】6.0. 数学工具
开发语言·后端·机器学习·rust·教程
IT_陈寒2 小时前
为什么我的JavaScript闭包总是漏掉那个变量?
前端·人工智能·后端
SomeOtherTime3 小时前
Postgresql触发器实现对表的日志审计
数据库·postgresql