2

I already found How do I change the default port (9000) that Play uses when I execute the "run" command?

But it has no answer to this.

This is specific to https://www.playframework.com/documentation/2.5.x/Deploying#Using-the-SBT-assembly-plugin

How can I change port when using assembly deployment option ?

I'm using

proc = new ProcessBuilder(

  "java",

  "-jar",

  "./lib/mode-assembley.jar",

  "-Dhttp.port=1234",

  "-Dplay.crypto.secret=abcdefghijk"



  ).start();

but this is still trying 9000 ! and getting

Bad root server path: /Users/xxxx/project/-Dhttp.port=1234

1 Answer 1

1

I think you're better off running your jar with the java parameter

java -jar ... -Dhttp.port=1234

Or alternatively (and my preferred approach), use different configuration files per environment.

So, in development mode you run:

sbt -Dconfig.resource=application.dev.conf run

And in the file conf/application.dev.conf have all the configuration you want for the development mode. Then in the conf/application.conf you can have the production configuration.

Remember that you can compose those files. So, write them like this:

conf/application.conf

# the assembly command will take this one.
http.port=9000

conf/application.dev.conf

include "application.conf"

#override configuration parameters here for dev mode.
http.port=1234

This way, when you do the assembly, you don't need to worry about it, since it takes by default the conf/application.conf file, the other one will be ignored unless you launch the jar with the parameter of course.

java -jar -Dconfig.resource=application.dev.conf

Or finally override anything with the java parameter

java -jar -Dconfig.resource=application.dev.conf -Dhttp.port=4321

This last one, will launch the app with the dev mode configuration and also overrides the port.

1
  • In the play application.conf, you nee to add play.server.http.port.
    – Thomas
    Feb 11, 2017 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.