简体   繁体   中英

IntelliJ - Java Gradle Run/Debug with args

I have a Spring application with Gradle and I run/debug it with bootRun task. This looks for the class with main method.

But sometimes I have to pass an argument for it, through main(String[] args) .

How can I do it from Run/Debug dialog? I tried VM options and Arguments, but when breakpoint get at args, it's empty.

As Command-Line Arguments in Spring Boot document describes, pass it for bootRun task as:

-Pargs=<arg1>,<arg2>

and in build.gradle :

bootRun {
  if (project.hasProperty('args')) {
      args project.args.split(',')
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM