如何更改play framework 2.5.9的http端口
How to change the http port for play framework 2.5.9
如何在Play 2.5.9 中将默认端口从9000 更改为9001?
尝试了以下步骤
- 更改 http.port = 9001 在 application.conf
- 尝试了本文中提到的步骤 post
[一个link]
但这行得通
激活剂运行-Dhttp.port=9001-Dhttp.address=127.0.0.1
我们可以从 application.conf 更改它而不是从命令行指定端口吗?
在某种程度上,不,您不能在重新加载模式 (activator run
) 的 application.conf
中添加 HTTP 服务器设置。
在 run
模式下播放服务器启动时,您的 application.conf
尚未解析,但如果您使用 state
则可以正常工作。
如果您想避免每次 运行 命令时都提供端口,您可以将其添加到 build.sbt
中,如下所示。
PlayKeys.devSettings := Seq("play.server.http.port" -> "9001")
说明here
从 2.5 版开始,您可以在 application.conf
中设置 Play 应用程序的端口,但是 此设置仅在 运行 生产中的应用程序时使用模式。
play.server {
# These settings only apply when running in production mode (e.g. when using the stage/dist task)
# To apply these settings in dev mode see:
# https://www.playframework.com/documentation/2.5.x/ConfigFile#Using-with-the-run-command
# https://groups.google.com/d/msg/play-framework/-EE28jmb4Uw/MBRQvAhhCwAJ
# https://www.playframework.com/documentation/2.5.x/ProductionConfiguration
# ~~~~~
http {
address = 127.0.0.1
port = 9000
}
#https {
# address = 127.0.0.1
# port = 9000
#}
}
要在开发模式下设置端口,您必须坚持 build.sbt
postet 中的设置。
最新版本(2.6.x) 带sbt,也可以用
sbt "run 9001"
如何在Play 2.5.9 中将默认端口从9000 更改为9001?
尝试了以下步骤
- 更改 http.port = 9001 在 application.conf
- 尝试了本文中提到的步骤 post
[一个link]
但这行得通 激活剂运行-Dhttp.port=9001-Dhttp.address=127.0.0.1
我们可以从 application.conf 更改它而不是从命令行指定端口吗?
在某种程度上,不,您不能在重新加载模式 (activator run
) 的 application.conf
中添加 HTTP 服务器设置。
在 run
模式下播放服务器启动时,您的 application.conf
尚未解析,但如果您使用 state
则可以正常工作。
如果您想避免每次 运行 命令时都提供端口,您可以将其添加到 build.sbt
中,如下所示。
PlayKeys.devSettings := Seq("play.server.http.port" -> "9001")
说明here
从 2.5 版开始,您可以在 application.conf
中设置 Play 应用程序的端口,但是 此设置仅在 运行 生产中的应用程序时使用模式。
play.server {
# These settings only apply when running in production mode (e.g. when using the stage/dist task)
# To apply these settings in dev mode see:
# https://www.playframework.com/documentation/2.5.x/ConfigFile#Using-with-the-run-command
# https://groups.google.com/d/msg/play-framework/-EE28jmb4Uw/MBRQvAhhCwAJ
# https://www.playframework.com/documentation/2.5.x/ProductionConfiguration
# ~~~~~
http {
address = 127.0.0.1
port = 9000
}
#https {
# address = 127.0.0.1
# port = 9000
#}
}
要在开发模式下设置端口,您必须坚持 build.sbt
最新版本(2.6.x) 带sbt,也可以用
sbt "run 9001"