方法一:

选择spring.profiles.active

spring.profiles.active=prod
spring.profiles.active=dev

几种激活Profile的方式

 

 

方法二:

选择spring.profiles.default

spring.profiles.default=prod
spring.profiles.default=dev

几种激活Profile的方式

 

 

如果当spring.profiles.active属性被设置时,那么Spring会优先使用该属性对应值来激活Profile。当spring.profiles.active没有被设置时,那么Spring会根据spring.profiles.default属性的对应值来进行Profile进行激活。如果上面的两个属性都没有被设置,那么就不会有任务Profile被激活,只有定义在Profile之外的Bean才会被创建。

 

方法三:使用@ActiveProfiles("dev")

几种激活Profile的方式

 

相关文章:

  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-01-08
  • 2021-05-25
  • 2022-12-23
猜你喜欢
  • 2021-08-20
  • 2022-12-23
  • 2021-09-23
  • 2023-01-16
  • 2022-12-23
  • 2021-07-20
相关资源
相似解决方案