play.application.loader [class java.lang.Class}] 没有实现接口 play.api.ApplicationLoader 或接口 play.ApplicationLoader

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

我的服务 运行 正常,直到我遇到 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}

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

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

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

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