1
0

More than 3 years have passed since last update.

SpringBootのapplication.ymlの環境別読み込みの方法

Last updated at Posted at 2021-08-26

環境変数を使う

起動オプションで指定する方法もあるみたいだが、現状はIntelliJから起動したり、eclipseから起動したり、VSCodeから起動したりするのでこっちの方が楽な気がした。

application-xxx.ymlという名前の設定ファイルを用意する。
環境変数にSPRING_PROFILES_ACTIVEというKEYを作成し、先に作ったapplication-xxx.ymlのxxxの部分をValueに指定する。
そのまま実行。IntelliJだとIDEを再起動しないと環境変数を読み込んでくれなった。
うまくいかない場合は環境変数のリロードを試すべき。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0