Search code examples
springspring-bootconfigurationgraalvmgraalvm-native-image

How to configure the port of a Spring Boot app that's natively compiled by GraalVM Native Image from command line?


Spring Boot introduces GraalVM Native Image support with the introduction of the Spring Graal Native 0.6.0 feature. Now if we have a successfully compiled native Spring Boot app, how can we dynamically change the port of an application at startup on the commandline (as we are used to in JVM mode)?

This is crucial for deployment scenarios with Docker or cloud providers...


Solution

  • As we're already used to do this in JVM mode like:

    java -Dserver.port=8087 -jar spring-boot-graal-0.0.1-SNAPSHOT.jar
    

    we can do the same with a natively compiled Spring Boot app:

    ./spring-boot-graal -Dserver.port=8087
    

    Thanks for the inspiration from Quarkus! See 100% comprehensible example project here: https://github.com/jonashackt/spring-boot-graalvm