LoginSignup
7

More than 5 years have passed since last update.

gradleでのjava起動オプションの設定

Last updated at Posted at 2016-10-31

gradleでのjava起動オプションの設定

jvmArgsに値を設定することでjava起動オプションが反映される。

build.gradle
jvmArgs = ['-Dspring.profiles.active=test']

gradle経由でspringテスト実行時のapplication.propertiesを切り替える

以下のように設定することでテスト実行時のプロパティファイルを
application.propertiesからapplication-test.propertiesに切り替えることが可能。

build.gradle
test {
  // テスト用プロパティファイルの読み込み(application-test.properties)
  jvmArgs = ['-Dspring.profiles.active=test'] 
}

参考サイト

application.propertiesの切替方法や読込順に関しては
以下のサイトが非常に詳しく記載してあって分かりやすいです。

Spring Bootの外部設定値の扱い方を理解する

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
What you can do with signing up
7