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

当前回答

在Windows上,“运行9001”可能无法运行。你必须改变play.bat文件。看到机票

其他回答

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

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

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

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

-Dhttp.port=9100

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

-Dconfig.file=<config_file_absolute_path>

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

sbt run

Play 2.3.x

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

在Windows上,“运行9001”可能无法运行。你必须改变play.bat文件。看到机票

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

例如

播放运行8080或播放开始8080

Play默认端口为9000