我試圖執行一個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