当在play控制台发出“run”命令时,如何更改开发模式下play框架使用的默认端口。

这是playframework 2.0测试版。

使用http。端口配置参数在命令行或在application.conf中似乎没有影响:

C:\dev\prototype\activiti-preso>play run --http.port=8080
[info] Loading project definition from C:\dev\prototype\activiti-preso\project
[info] Set current project to activiti-preso (in build file:/C:/dev/prototype/activiti-preso/)


Windows, really? Ok, disabling colors.

--- (Running the application from SBT, auto-reloading is enabled) ---

[error] org.jboss.netty.channel.ChannelException: Failed to bind to: 0.0.0.0/0.0.0.0:9000
[error] Use 'last' for the full log.

当前回答

只需在build.sbt中添加以下行

PlayKeys.devSettings:= Seq("play.server.http. play. devsettings . "端口" -> "8080")

其他回答

我做了这个。须道是必要的。

$ sudo play debug -Dhttp.port=80
...
[MyPlayApp] $ run

编辑:我有问题,因为使用sudo所以要小心。最后,我清理了这个项目,不再使用这个技巧了。

玩2.0 rc4

在要运行的play命令周围包含引号是很重要的。在我的情况下,没有引号发挥仍然运行在端口9000。

play "run 8080"

或者,您可以从播放控制台运行以下命令(键入'play'以进入控制台)

run 8080

使用2.3.7 Play框架测试。工作得很好。

./{application}/bin/{executable} -Dhttp.port=5000

希望这能帮助到一些人。

通过SBT设置:

...
.settings(PlayKeys.playDefaultPort := 8855)
...

在windows上,我使用这样的start.bat文件:

java -Dhttp.port=9001 -DapplyEvolutions.default=true -cp "./lib/*;" play.core.server.NettyServer "."

- dapplyevoludings .default=true告诉evolution自动应用evolution而不需要确认。当然,在生产环境中使用时要谨慎……