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

在要运行的play命令周围包含引号是很重要的。在我的情况下,没有引号发挥仍然运行在端口9000。

play "run 8080"

或者,您可以从播放控制台运行以下命令(键入'play'以进入控制台)

run 8080

其他回答

Play 2.3.x

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

在Windows上播放2.2.0

使用zip发行版(使用“dist”命令生成),我能够更改启动端口的唯一方法是首先设置JAVA_OPTS,然后启动应用程序。

例如,从命令行

set JAVA_OPTS=-Dhttp.port=9002
bin\myapp.bat

其中myapp.bat是由dist命令创建的批处理文件。

下面的代码总是会忽略我的http。端口参数,并尝试在默认端口9000上启动

bin\myapp.bat -Dhttp.port=9002

然而,我注意到这在Linux/OSX上工作得很好,在请求的端口上启动:

./bin/myapp -Dhttp.port=9002

在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文件。看到机票

播放2.5.x

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

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

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

-Dhttp.port=9005

步骤4:启动服务器

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