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

当前回答

Play 2.5。Play 2.6.x

sbt "-Dhttp.port=9002"

然后

run

其他回答

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

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

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

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

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

Play 2.2。我在可分配根目录中创建了一个名为{PROJECT_NAME}_config.txt的文件,并添加:

-Dhttp.port=8080

其中{PROJECT_NAME}应该替换为您的项目名称。然后像往常一样在bin\目录中启动{PROJECT_NAME}.bat脚本。

Windows上的Play 2.2.1支持PLAY_OPTS环境变量。Play的Play .bat文件包含这一行:

java -Dsbt.ivy.home="%~dp0repository" -Dplay.home="%~dp0framework" -Dsbt.boot.properties="%fp%framework/sbt/play.boot.properties" %PLAY_OPTS% -jar "%~dp0framework\sbt\sbt-launch.jar" %*

因此,要在端口9002上运行,请执行

set PLAY_OPTS=-Dhttp.port=9002
play run

我们使用的是Play 2.5.6版本。

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

就是这样。