2015-02-07 32 views
0

我正试图学习PlayScalaGuice此刻,我遇到了与version 2.3.7 of Play有关的问题。当我通过更改插件启动示例时。 sbt的播放版本为2.3.6该应用程序的ApplicationController正常加载。但是,当在plugins.sbt中切换到2.3.7时,我只是得到一个空白页面。为什么Play v2.3.6与Guice一起使用但不能播放v2.3.7?

我组合了Play-Guice示例(使用早期版本的Play构建)和Slick数据访问示例。

这里是我的Application.scala播放器的代码,而包装和进口:

@Singleton 
class Application @Inject() (textGenerator: TextGenerator) extends Controller { 

    def index = Action { 
    Ok(views.html.index(textGenerator.welcomeText)) 
    } 

} 

object Application extends Controller { 
    def index = Action { 
    Ok(views.html.index("Your new application is ready.", "Home")) 
    } 
} 

这里是我的Global.scala(减去进口):

object Global extends GlobalSettings { 

    /** 
    * Bind types such that whenever TextGenerator is required, an instance of WelcomeTextGenerator will be used. 
    */ 
    val injector = Guice.createInjector(new AbstractModule { 
    protected def configure() { 
     bind(classOf[TextGenerator]).to(classOf[WelcomeTextGenerator]) 
    } 
    }) 

    /** 
    * Controllers must be resolved through the application context. There is a special method of GlobalSettings 
    * that we can override to resolve a given controller. This resolution is required by the Play router. 
    */ 
    override def getControllerInstance[A](controllerClass: Class[A]): A = injector.getInstance(controllerClass) 
} 

任何人都可以看到,为什么播放的一个版本会工作,但不是其他?

任何信息请求或受过教育的猜测也欢迎!

注意:到目前为止没有明显的错误信息,我在两个版本中看到的唯一区别是一个加载页面,另一个不加载页面。没有已知的记录错误,错误消息或代码差异(当然不包括版本切换)。

Build.scala(减去进口):

object ApplicationBuild extends Build { 

    val appName   = "root" 
    val appVersion  = "1.0-SNAPSHOT" 

    val appDependencies = Seq(
    "com.google.inject" % "guice" % "3.0", 
    "javax.inject" % "javax.inject" % "1", 

    "org.mockito" % "mockito-core" % "1.9.5" % "test" 
) 


    val main = Project(appName, file(".")).enablePlugins(play.PlayScala).settings(
    version := appVersion, 
    libraryDependencies ++= appDependencies 
) 

} 
+0

SBT shell的任何输出? – Mikesname 2015-02-07 15:28:14

+0

@Mikesname - 我在播放运行选项卡日志窗口中看不到太多,只是典型的启动消息。我会看看我是否可以确定是否有任何其他日志记录丢失。此外,我正在考虑将记录添加到控制器,这可能会有所帮助。 – 2015-02-07 15:40:07

+0

我使用4.0-beta5,我的应用程序在2.3.7(及更早版本)上运行。 – 2015-02-09 09:02:12

回答

0

后来我回去,并试图为@akkie建议切换回2.3.7,网站能正常启动和工作。

回过头来看看有两种可能性导致网站失败。

要么

  1. 接线了华而不实的数据访问凭据允许服务器 开始用分贝谈话之后。
  2. 出于某种原因,我不是用最新版本

承受一定的工作记住,这些都只是猜测,所以我可能已经错过了一些其他的变化,帮助解决问题。尽管如此,我认为我或其他人可能会通过阅读我的笔记,以帮助其后得到帮助。

相关问题