3

i added some code inside Global.scala, and application.conf application.global=Global

object Global extends WithFilters(new GzipFilter()) with GlobalSettings {
  override def onStart(app: Application) {
    Logger.info("Application started.")
  }

  override def onStop(app: Application) {
    Logger.info("Application shutdown...")
  }
}

Why run 3 times in conole ?

[info] application - Application started.
[info] application - Application started.
[info] application - Application started.
[info] wobo - Application started (Dev)
[WARN] [10/21/2013 15:54:50.591] [New I/O worker #1] [EventStream(akka://play)]akka.event-handlers] config is deprecated, use [akka.loggers]
[info] application - Application shutdown...
[info] application - Application shutdown...
[info] application - Application shutdown...
4

1 回答 1

2

OnStart is might called multiple times because you have dependencies to Play plugins that are older than your application Play version.

You can exclude the older Play dependencies in SBT, for example how to do it for the typesafe mail plugin in build.sbt or Build.scala:

 "com.typesafe" %% "play-plugins-mailer" % "2.2.0" exclude ("org.scala-stm", "scala-stm_2.10.0") exclude("play", "*")

I think it happens because Play has a new Group ID so SBT does not recognize it as the same library.

于 2013-10-21T13:32:31.250 回答