小编Roy*_*Lin的帖子

PlayFramework 2.4在应用程序启动后运行一些代码

在Play 2.4中,覆盖ApplicationLoader中的builder方法或在Abstract模块中实现EagerBinding将替换现有的play 2.3 GlobalSettings onStart.

但是在onStart方法2.3中,您的应用程序已经开始加载所有插件/依赖项.你可以在游戏2.4中做同样的事情,即在应用程序启动后运行一段代码.

在我的情况下,Slick要求应用程序在它可以访问数据库之前已经启动.

谢谢

playframework playframework-2.4

8
推荐指数
2
解决办法
2204
查看次数

是否可以在普通的sql Slick中使用IN子句来表示整数?

这里有一个类似的问题,但实际上并没有回答这个问题.

是否可以在普通的sql Slick中使用IN子句?

请注意,这实际上是更大,更复杂的查询的一部分,所以我需要使用普通的sql而不是光滑的提升嵌入.像下面这样的东西会很好:

val ids = List(2,4,9)
sql"SELECT * FROM coffee WHERE id IN ($ids)"
Run Code Online (Sandbox Code Playgroud)

scala slick

7
推荐指数
2
解决办法
2643
查看次数

在play 2.4中的logback配置,$ {application.home}定义在哪里?

此处的链接显示了如何配置自定义记录器.

https://www.playframework.com/documentation/2.4.x/SettingsLogger

我只是想知道$ {applicaation.home}在哪里定义,因为它似乎没有在我的生产环境中定义.

playframework playframework-2.4

6
推荐指数
1
解决办法
4237
查看次数

playframework 2.4 GlobalSettings onStart已弃用

我正在将我的应用从2.3播放到2.4.

在我的GlobalSettings中的2.3应用程序中,我不得不使用光滑访问数据库来创建postgres数据库功能.

由于GlobalSettings在2.4中已弃用,因此替代方法是使用Eager Bindings:

https://www.playframework.com/documentation/2.4.x/ScalaDependencyInjection#Eager-bindings

像这样:

class MyModule extends AbstractModule {
  def configure() = {
    db.withSession { implicit ss =>
      StaticQuery.update("""CREATE OR REPLACE FUNCTION ... """).execute
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

但这给了我错误:

java.lang.ExceptionInInitializerError: 
     core.includes$.<init>(includes.scala:14)
     core.includes$.<clinit>(includes.scala)
     Application$$anonfun$configure$1.apply(Application.scala:17)
     Application$$anonfun$configure$1.apply(Application.scala:15)
     scala.slick.backend.DatabaseComponent$DatabaseDef$class.withSession(DatabaseComponent.scala:34)
     scala.slick.jdbc.JdbcBackend$DatabaseFactoryDef$$anon$4.withSession(JdbcBackend.scala:61)
     modules.jdbc.Database$$anonfun$withSession$1.apply(Database.scala:14)
     modules.jdbc.Database$$anonfun$withSession$1.apply(Database.scala:14)
     Application.configure(Application.scala:15)
     com.google.inject.AbstractModule.configure(AbstractModule.java:62)
     com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
     com.google.inject.spi.Elements.getElements(Elements.java:110)
     com.google.inject.util.Modules$OverrideModule.configure(Modules.java:177)
     com.google.inject.AbstractModule.configure(AbstractModule.java:62)
     com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:340)
     com.google.inject.spi.Elements.getElements(Elements.java:110)
     com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:138)
     com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
     com.google.inject.Guice.createInjector(Guice.java:96)
     com.google.inject.Guice.createInjector(Guice.java:73)
     com.google.inject.Guice.createInjector(Guice.java:62)
     play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126)
     play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93)
     play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
Run Code Online (Sandbox Code Playgroud)

有没有人知道如何解决这个问题?谢谢.

playframework playframework-2.4

2
推荐指数
1
解决办法
4227
查看次数

标签 统计

playframework ×3

playframework-2.4 ×3

scala ×1

slick ×1