常用配置:更改服務(wù)端口號(hào) , 默認(rèn)的端口號(hào)是8080
yaml

yaml配置
//注意springboot版本不一樣的時(shí)候,格式會(huì)有些出入, 本次的SpringBoot :: (v2.5.8)
server:
port:7777
servlet:
session:
timeout: 30m #測(cè)試的話 需要長(zhǎng)一些
config:
key:YYYYY
多環(huán)境配置
1. 在配置文件中指定啟動(dòng)某個(gè)環(huán)境
創(chuàng)建一個(gè)application.yaml 并指定active的值 就會(huì)啟動(dòng)該值對(duì)應(yīng)的配置文件
運(yùn)行的時(shí)候 會(huì)自動(dòng)讀取該文件 中active對(duì)應(yīng)的值 比如test 那會(huì)將application.yaml作為啟動(dòng)時(shí)應(yīng)該使用的配置文件
spring:
profiles:
active: test
創(chuàng)建一個(gè)application-test.yaml
server:
port: 8888
servlet:
session:
timeout: 30m #測(cè)試的話 需要長(zhǎng)一些
config:
key: TTTTT
創(chuàng)建一個(gè)application-dev.yaml
server:
port: 7777
servlet:
session:
timeout: 30m #測(cè)試的話 需要長(zhǎng)一些
config:
key: YYYYY
2. pom文件添加profiles
<profiles>
<profile>
<id>
dev
</id>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>
test
</id>
<properties>
<spring.profiles.active>test</spring.profiles.active>
</properties>
</profile>
<profile>
<id>
uat
</id>
<properties>
<spring.profiles.active>uat</spring.profiles.active>
</properties>
</profile>
</profiles>
3. sh腳本指定

.sh文件