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

当前回答

你可以在项目根目录下的.jvmopts文件中设置其他选项:

-Dhttp.port=9100

您还可以添加其他选项,如加载不同的配置文件

-Dconfig.file=<config_file_absolute_path>

在你设置了.jvmopts文件之后,你不需要记得在命令行中添加一些参数,只需要这样做:

sbt run

其他回答

版本2.0.3:

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

我希望这能有所帮助。

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

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

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

在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”。

就是这样。

Play 2.3.x

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