1. 多配置文件
官网查看配置文件可以存放哪些位置:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config
file:表示项目目录下
2. 切换环境
2.1 方式一
application.properties
server.port=8080
#指定开启哪个环境
spring.profiles.active=dev
application-dev.properties
server.port=8080
application-test.properties
server.port=8081
2.2 方式二
application.yaml
#默认端口号
server:
port: 8080
#指定环境
#设置开发环境
spring:
profiles:
active: test
---
server:
port: 8081
spring:
profiles: dev
---
#设置测试环境
server:
port: 8082
spring:
profiles: test
配置项目的访问路径
#配置项目的访问路径
server.servlet.context-path=/t1
内容参考:https://www.bilibili.com/video/BV1PE411i7CV?t=713
仅用于学习!