编程语言
首页 > 编程语言> > java – 配置错误[未设置应用程序密钥]

java – 配置错误[未设置应用程序密钥]

作者:互联网

我在生产模式下运行Play 2.4服务器时遇到此错误:

play.api.UnexpectedException: Unexpected exception[ProvisionException: Unable to provision, see the following errors:

1) Error in custom provider, @6mh5cjo5l: Configuration error
  while locating play.api.libs.CryptoConfigParser
  while locating play.api.libs.CryptoConfig

...

Caused by: play.api.PlayException: Configuration error[Application secret not set]

怎么修?

解决方法:

默认的Play模板使用以下内容:

play.crypto.secret="changeme"

在application.conf中需要更改才能在生产中使用. Play提供了一个实用程序来为您生成随机秘密:

./activator playGenerateSecret

然后,您可以使用它作为环境变量填充:

APPLICATION_SECRET=...

并在conf / application.conf中确保以下内容:

play.crypto.secret="changeme"
play.crypto.secret=${?APPLICATION_SECRET}

正如Play documentation解释的那样:

The second line in that configuration sets the secret to come from an
environment variable called APPLICATION_SECRET if such an environment
variable is set, otherwise, it leaves the secret unchanged from the
previous line.

然后错误就会消失.

标签:java,scala,playframework,playframework-2-4
来源: https://codeday.me/bug/20190724/1527570.html