Search code examples
spring-bootgrails

Grails 4: Standalone port


I'm using Grails 4.x and create a runnable war via

grails war

command. I can run it via

java -jar myapp.jar

I would like to change the port dynamically via parameter, and tried

-Dgrails.server.port.http=8083

but with no success. It still runs on default port 8080. Earlier with Grails 2.3.6, it worked with parameter port=808.

I cannot find anything in the documentation (http://docs.grails.org/3.1.1/ref/Command%20Line/war.html)


Solution

  • If you assign a value to the server.port system property, that value will be used.

    ~ $ grails -version
    | Grails Version: 4.0.5
    | JVM Version: 1.8.0_202
    ~ $ 
    ~ $ grails create-app sullivanportdemo
    | Application created at /Users/jeffscottbrown/sullivanportdemo
    ~ $ 
    ~ $ cd sullivanportdemo 
    sullivanportdemo $ ./gradlew assemble
    Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
    
    BUILD SUCCESSFUL in 19s
    7 actionable tasks: 7 executed
    sullivanportdemo $ 
    sullivanportdemo $ java -jar build/libs/sullivanportdemo-0.1.war 
    Grails application running at http://localhost:8080 in environment: production
    
    sullivanportdemo $ 
    sullivanportdemo $ java -Dserver.port=8084 -jar build/libs/sullivanportdemo-0.1.war
    Grails application running at http://localhost:8084 in environment: production