【问题标题】:play.application.loader [class java.lang.Class}] does not implement interface play.api.ApplicationLoader or interface play.ApplicationLoaderplay.application.loader [class java.lang.Class}] 没有实现接口 play.api.ApplicationLoader 或接口 play.ApplicationLoader
【发布时间】:2021-10-13 04:19:04
【问题描述】:

在我遇到此错误的 api 端点请求之前,我的服务运行良好-

 Cannot load play.application.loader[play.application.loader [class java.lang.Class}] does not implement interface play.api.ApplicationLoader or interface play.ApplicationLoader.]

我的服务加载器:-

class LagomPersistentEntityLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext): LagomApplication =
    new LagomPersistentEntityApplication(context)  with AkkaDiscoveryComponents

  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new LagomPersistentEntityApplication(context) with LagomDevModeComponents

  override def describeService: Option[Descriptor] = Some(readDescriptor[LagomTestingEntity])
}

trait UserComponents
  extends LagomServerComponents
    with SlickPersistenceComponents
    with HikariCPComponents
    with AhcWSComponents {

  override lazy val jsonSerializerRegistry: JsonSerializerRegistry = UserSerializerRegistry

  lazy val userRepo: UserRepository = wire[UserRepository]
  readSide.register(wire[UserEventsProcessor])

  clusterSharding.init(
    Entity(UserState.typeKey){ entityContext =>
      UserBehaviour(entityContext)
    }
  )
}

abstract class LagomPersistentEntityApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
    with UserComponents {

  implicit lazy val actorSystemImpl: ActorSystem   = actorSystem
  implicit lazy val ec: ExecutionContext           = executionContext


  override lazy val lagomServer: LagomServer = serverFor[LagomTestingEntity](wire[LagomTestingEntityImpl])

  lazy val bodyParserDefault: Default = wire[Default]

}

application.conf:-

play.application.loader = org.organization.service.LagomTestingEntityImpl

lagom-persistent-entity.cassandra.keyspace = lagom-persistent-entity

cassandra-journal.keyspace = ${lagom-persistent-entity.cassandra.keyspace}

cassandra-snapshot-store.keyspace = ${lagom-persistent-entity.cassandra.keyspace}

lagom.persistent.read-side.cassandra.keyspace = ${lagom-persistent-entity.cassandra.keyspace}

此服务同时支持读取端和写入端,如果有人需要代码中的更多信息,请询问,因为我真的很想了解应用程序失败的地方。

【问题讨论】:

    标签: scala playframework lagom


    【解决方案1】:

    您应该将play.application.loader 设置为您的加载器类的名称,而不是您的持久实体类:

     play.application.loader = org.organization.service.LagomPersistentEntityLoader
    

    我假设LagomPersistentEntityLoaderLagomTestingEntityImpl 在同一个包中。如果不是,则根据需要调整完全限定的类名。

    【讨论】:

      猜你喜欢
      • 2019-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多