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

当前回答

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

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

其他回答

版本2.0.3:

转到项目目录,只说play(在那之后什么都没有)。 这将打开播放控制台。 接下来,运行8080。这将在端口8080上开始播放。

我希望这能有所帮助。

希望这能帮助到一些人。

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

播放2.5.x

步骤1:使用control + D停止netty服务器(如果它正在运行)

步骤2:进入sbt-dist/conf目录

步骤3:编辑这个文件“sbtConfig.txt”

-Dhttp.port=9005

步骤4:启动服务器

第五步:http://host:9005/

Play 2.3.x

激活器"run -Dhttp.port=9001"