1、application.properties中添加spring.profiles.active=test

2、同级目录下创建application-dev.properties、application-test.properties、application-prod.properties三个文件。

3、定义端口

application-dev.properties中

#开发环境
server.port=8080

 

application-test.properties中

#测试环境
server.port=8081

 

pplication-prod.properties中

#生产环境
server.port=8082

 

备注:

在此一定要注意:

profile的配置文件可以按照application.properyies的放置位置一样,放于以下四个位置,

1.当前目录的 “/config”的子目录下

2.当前目录下

3.classpath根目录的“/config”包下

4.classpath的根目录下

相关文章:

  • 2022-01-26
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2021-04-01
  • 2022-01-15
猜你喜欢
  • 2021-11-28
  • 2021-07-08
  • 2021-07-23
  • 2021-12-24
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
相关资源
相似解决方案