0

I'd like to add -Xmx6g as a command line argument to a spring boot application that is launched with maven via mvn spring-boot:run. I do this easily enough with Intellij, but I would like to launch the application manually from my terminal so that I have some extra ram.

I've tried to configure in the Maven Surefire Plugin, but this hasn't worked. Could anyone share a working snippit?

Danubian Sailor
  • 22,047
  • 37
  • 140
  • 217
MrUwugu
  • 1
  • 1
  • The [Spring docs](https://docs.spring.io/spring-boot/docs/2.7.x/reference/htmlsingle/#using.running-your-application.with-the-maven-plugin) suggest to set those via [`MAVEN_OPTS`](https://maven.apache.org/configure.html#maven_opts-environment-variable), e.g. `export MAVEN_OPTS=-Xmx6g` - does that help? – Christian Jun 02 '22 at 21:17
  • Alternatively [`jvmArguments`](https://docs.spring.io/spring-boot/docs/2.2.2.RELEASE/maven-plugin/run-mojo.html#jvmArguments) ([current docs](https://docs.spring.io/spring-boot/docs/2.7.x/maven-plugin/reference/htmlsingle/#run)) as per https://stackoverflow.com/a/68069089/2018047 – Christian Jun 02 '22 at 21:24
  • 1
    @Christian: in the documentation you've provided, I'm confused as to why an example cannot be provided. Firstly, I imagine such a command might look like mvn spring-boot:run jvmArguments="-Xmx6g" but, this isn't explicitly stated anywhere. What's worse is that the documentation also says "NOTE: [something important about needing a forked process", and I have a feeling that I would also need an example of how to specify that I would like to launch with a forked process. This is a bit tedious compared to how this works in the java command line, so I think asking for an example is ok. – MrUwugu Jun 02 '22 at 22:30

0 Answers0