开发模式
我们在做开发的时候 一般有这么些情况
开发----开发状态
测试-----测试状态
部署-----生产状态
我们在做开发的时候 有可能 开发的环境和 测试的环境 以及 生产的环境不是一个环境
那么这个时候我们在做开发的时候 就需要将这些 环境给分隔开
在不同的时期 就使用功能不同的配置文件来完成项目的测试
那么我们的springboot中 如何来区分这三种模式呢?
# properties文件写法
# 激活某一种模式的配置文件 以 test 结尾
spring.profiles.active=test
1
2
2
# yml文件写法
spring:
profiles:
active: dev
1
2
3
2
3
# yml另外一种写法
spring:
profiles:
active: dev
---
spring:
profiles: dev
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql:///user
username: root
password: root
type: com.alibaba.druid.pool.DruidDataSource
server:
port: 8089
mybatis:
mapper-locations: classpath:/*.xml
type-aliases-package: com.xf.springboot.pojo
---
spring:
profiles: test
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql:///user
username: root
password: root
type: com.alibaba.druid.pool.DruidDataSource
server:
port: 9090
mybatis:
mapper-locations: classpath:/*.xml
type-aliases-package: com.xf.springboot.pojo
---
spring:
profiles: prod
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql:///user
username: root
password: root
type: com.alibaba.druid.pool.DruidDataSource
server:
port: 9999
mybatis:
mapper-locations: classpath:/*.xml
type-aliases-package: com.xf.springboot.pojo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
最近更新: 2024/12/26, 17:36:00