Spring use one application.properties for production and another for debug

后端 未结 2 2009
盖世英雄少女心
盖世英雄少女心 2020-12-29 21:14

I have a Spring application and I would like to be able to switch between configurations depending if I\'m debugging the server or if the server is running in production. (t

2条回答
  •  独厮守ぢ
    2020-12-29 21:37

    You can have 3 properties files, application-dev.properties, application-prod.properties and application.properties. And you can specify all the development properties in your dev properties file and production cionfiguration properties in your prod file

    and specify the profile in your application.properties files as below

    spring.profiles.active=dev
    

    or you can select/override the profile using -Dprofile= argument in command line.

提交回复
热议问题