如何更改播放框架 2.4.1 的 http 端口?

How to change the http port for play framework 2.4.1?

我来自 play 1.2.7 应用程序,目前开始使用 play framework 2.4.1 和 scala。首先,我使用 activator web ui 来管理应用程序,但我无法让应用程序使用不同的 http 端口。

我更改了 conf/application.conf 中的 http.port 设置,但仍然玩 2.4.1 尝试绑定到已被使用的端口 9000。我试过的设置是:

http.port=7000

关于如何通过激活器网络更改 运行 play framework 2.4.1 应用程序端口的任何建议 ui?

请注意,按照链接问题中的建议,我可以使用

./activator "run 7000"

在应用程序本身中将其绑定到端口 7000。我的问题仍然是如何通过激活器网络获得相同的行为ui?

将以下内容添加到项目的 build.sbt 中,其中 <port> 应替换为所需的端口号。

build.sbt

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

A​​ctivator UI 中的预期控制台输出 运行

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...)

通过 application.conf 生产:

play.server.http.port = 80

当您 运行 使用 SBT 申请时:

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

使用run命令:

$ run 80

更多详情请参考以下链接:

documentation-Config File

documentation-Server configuration options

关于 run 命令的简短说明(使用 Play! 2.4 测试):

至少在 Windows activator run -Dhttp.port=80 上不起作用,但是 activator(回车)然后 run -Dhttp.port=80 起作用

试试这个:

activator "run 9500"

在您项目文件夹的终端中。

这个命令对我有用:

activator "~run 3333"