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. 技巧

相关推荐
uhakadotcom3 分钟前
Apache CXF 中的拒绝服务漏洞 CVE-2025-23184 详解
后端·面试·github
uhakadotcom5 分钟前
CVE-2025-25012:Kibana 原型污染漏洞解析与防护
后端·面试·github
uhakadotcom5 分钟前
揭秘ESP32芯片的隐藏命令:潜在安全风险
后端·面试·github
随风九天6 分钟前
Spring Boot + MyBatis + MySQL:快速搭建CRUD应用
spring boot·mysql·mybatis
uhakadotcom10 分钟前
Apache Camel 漏洞 CVE-2025-27636 详解与修复
后端·面试·github
uhakadotcom13 分钟前
OpenSSH CVE-2025-26466 漏洞解析与防御
后端·面试·github
uhakadotcom20 分钟前
PostgreSQL的CVE-2025-1094漏洞解析:SQL注入与元命令执行
后端·面试·github
zhuyasen27 分钟前
Go语言开发实战:app库实现多服务启动与关闭的优雅方案
后端·go
勘察加熊人29 分钟前
fastapi房产销售系统
数据库·lua·fastapi
ITlinuxP32 分钟前
2025最新Postman、Apipost和Apifox API 协议与工具选择方案解析
后端·测试工具·postman·开发工具·apipost·apifox·api协议