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

当前回答

随着今天(11月25日)引入的提交,您现在可以在run或start sbt命令之后指定端口号。

例如

播放运行8080或播放开始8080

Play默认端口为9000

其他回答

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

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

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

我们使用的是Play 2.5.6版本。

要更改端口,请转到项目根文件夹并点击: 在命令提示符/终端激活“run 8008”。

就是这样。

在2.8版中。X你可以使用特定的资源文件或特定的端口运行(如果只运行sbt,你将使用application.conf和默认端口9000)

sbt运行-dconfig.resource=application.local.conf -dhttp.port=9002

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

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

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

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

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