我一次又一次地在运行时遇到同样的错误:
Cannot initialize the custom Global object (%s) (perhaps it's a wrong reference?)
In me/myapp/conf/application.conf at line 5.
application.global=common.Global
其中
package common
object Global extends GlobalSettings {
//...
}
顺便说一句,我在Contoller的动作中使用Global
。
奇怪的是,如果我在application.global=common.Global
/conf/application.conf
行
# application.global=common.Global
然后错误就会消失。
我正在使用Scala 2.10.3
,Play 2.1.3
和sbt.version = 0.12.4
//project/build.properties
sbt.version=0.12.4
//project/Build.scala
object ApplicationBuild extends Build {
//.....
lazy val buildSettings = Seq(
organization := "myapp",
version := "1.0-SNAPSHOT123",
scalaVersion := "2.10.3"
)
}
//project/plugins.sbt
// Comment to get more information during initialization
logLevel := Level.Warn
// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2.1.3")
你的想法?
答案 0 :(得分:3)
确保您的common
包放在app
文件夹内和/或检查名称中的拼写错误。像魅力一样。
错误消失,因为它是Play的默认行为 - 如果默认路径中没有Global对象,它只会认为根本不存在。
答案 1 :(得分:0)
也可能与app配置调用的循环引用有关的问题: