Add JVM args to spring boot application

6.9k views Asked by At

I'm running Spring Boot application based on Gradle. I need to somehow add JVM arguments to this project, so when I run project using "java -jar myProject", JVM arguments were loaded automatically.

1

There are 1 answers

1
victor.hernandez On

Just add this line to your build.gradle file and you will be able to pass options to the JVM (for instance -Dspring.profiles.active=loc):

bootRun.systemProperties = System.properties

The whole build.gradle file should look like something like this:

project.ext {
    ...
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'

repositories {
    ....
}

dependencies {
    runtime ...

    compile ...
    compile ...

    testCompile ...
}

jar {
    ...
}

bootRun.systemProperties = System.properties