How to change the http port for play framework 2.4.1?

前端 未结 5 1992
我寻月下人不归
我寻月下人不归 2021-01-14 15:11

I come from a play 1.2.7 application and currently getting started with play framework 2.4.1 and scala. For a start I use the activator web ui to manage applications and the

相关标签:
5条回答
  • 2021-01-14 15:32

    Add the following to build.sbt of your project where <port> should be replaced with your desired port number.

    build.sbt

    fork in run := true
    javaOptions in run += "-Dhttp.port=<port>"
    

    Expected console output in Activator UI on run

    Setting up Play fork run ... (use Ctrl+D to cancel)
    
    --- (Running the application, auto-reloading is enabled) ---
    
    p.a.l.c.ActorSystemProvider - Starting application default Akka system: application
    p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:<port>
    
    (Server started, use Ctrl+D to stop and go back to the console...)
    
    0 讨论(0)
  • 2021-01-14 15:43

    Through the application.conf in production:

    play.server.http.port = 80
    

    When you run the application with SBT:

    PlayKeys.devSettings := Seq("play.server.http.port" -> "80")
    

    Using run command:

    $ run 80
    

    For more details please refer the below links:

    documentation-Config File

    documentation-Server configuration options

    0 讨论(0)
  • 2021-01-14 15:46

    Just a short note concerning the run command (tested with Play! 2.4):

    At least on Windows activator run -Dhttp.port=80 does NOT work, but activator (hit enter) and then run -Dhttp.port=80 works

    0 讨论(0)
  • 2021-01-14 15:50

    Try this out:

    activator "run 9500"
    

    in terminal from your project folder.

    0 讨论(0)
  • 2021-01-14 15:51

    This command work for me guys:

    activator "~run 3333"
    
    0 讨论(0)
提交回复
热议问题