我试图执行一个akka-http,它是一个scala程序。我的吻代码如下: -非法继承,超类X不是mixin特征Z的超类Y的子类Z-Scala
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.directives.BasicDirectives
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Flow
import com.typesafe.config.ConfigFactory
object MyBoot02 extends SprayCanBoot02 with RestInterface02 with App {
}
abstract class SprayCanBoot02 {
val config = ConfigFactory.load()
val host = config.getString("http.host")
val port = config.getInt("http.port")
implicit val system = ActorSystem("My-ActorSystem")
implicit val executionContext = system.dispatcher
implicit val materializer = ActorMaterializer()
//implicit val timeout = Timeout(10 seconds)
implicit val routes: Flow[HttpRequest, HttpResponse, Any]
Http().bindAndHandle(routes, host, port) map {
binding => println(s"The binding local address is ${binding.localAddress}")
}
}
trait RestInterface02 extends AncileDemoGateway02 with Resource02 {
implicit val routes = questionroutes
val buildMetadataConfig = "this is a build metadata route"
}
trait Resource02 extends QuestionResource02
trait QuestionResource02 {
val questionroutes = {
path("hi") {
get {
complete("questionairre created")
}
}
}
}
class AncileDemoGateway02 {
println("Whatever")
}
,我得到试图执行MyBoot02的时候是因为如何,我的东西接线错误。错误如下:
Error:(58, 41) illegal inheritance; superclass SprayCanBoot is not a subclass of the superclass AncileDemoGateway of the mixin trait RestInterface object MyBoot extends SprayCanBoot with RestInterface with App
为什么错误状态“SprayCanBoot不超AncileDemoGateway的子类”。在我的代码中,SprayCanBoot和AncileDemoGateway是2个独立的实体,那么为什么会出现这样的错误?
由于
你能否提供一个参考答案。我认为这不是问题。谢谢 – BigDataScholar
MyBoot02的超类是SprayCanBoot02,RestInterface02的超类是AncileDemoGateway02。由于'SprayCanBoot02'不是'AncileDemoGateway02'的子类,因此它不能编译。 – Sebastian