LoginSignup
6
1

More than 5 years have passed since last update.

MavenのSpringBootで環境別の起動方法

Last updated at Posted at 2018-05-30

springBootで開発中にキャッシュの設定など環境別に分ける方法です。

まず環境別のapplication.ymlを作成し、設定を書いて行きます。

$ touch resources/application-dev.yml
$ touch resources/application-test.yml

あとはmavenの起動時にオプションを追記します。
そうすると環境ごとのapplication.ymlが読み込まれます。

// application-dev.ymlが読み込まれる
$ maven spring-boot:run -Drun.profiles=dev
// application-test.ymlが読み込まれる
$ maven spring-boot:run -Drun.profiles=test

補足 SpringBoot2.0移行は以下の通りです。

$maven spring-boot:run -Dspring-boot.run.profiles=dev
$maven spring-boot:run -Dspring-boot.run.profiles=test
6
1
2

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
6
1