当在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.

当前回答

希望这能帮助到一些人。

通过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而不需要确认。当然,在生产环境中使用时要谨慎……

在Windows上,“运行9001”可能无法运行。你必须改变play.bat文件。看到机票

我们不能从激活器更改应用程序端口,但可以从命令行激活器“~run 8080”更改。

但是要从激活器上运行poet 9000,我们需要停止正在使用该端口的应用程序。我们可以使用this应用程序来查找并结束该过程https://technet.microsoft.com/en-in/sysinternals/bb897437.aspx

在此之后,我们可以运行,它将成功。

你也可以在项目目录的.sbtopts中设置HTTP端口:

-Dhttp.port=9001

这样就不必每次都记得将其添加到运行任务中。

使用Play 2.1.1测试。

指定开发中的端口

缺省情况下,SBT在9000端口上运行应用程序:

sbt run

使用实例指定端口add -Dhttp。端口标志,例如:

sbt run -Dhttp.port=8080

使用-Dhttp。端口标志,您可以在开发机器上调试多个应用程序。请注意,您也可以使用-Dhttp。测试和生产环境中的端口标志。