【发布时间】:2017-05-08 21:45:38
【问题描述】:
我正在尝试执行一个 akka-http,它是一个 scala 程序。我的 KISS 代码如下:-
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 时接线的方式。错误如下:
错误:(58, 41) 非法继承;超类 SprayCanBoot 不是 mixin trait 的超类 AncileDemoGateway 的子类 RestInterface 对象 MyBoot 使用 RestInterface 扩展 SprayCanBoot 与应用程序
为什么错误状态为“SprayCanBoot 不是超类 AncileDemoGateway 的子类”。在我的代码中,SprayCanBoot 和 AncileDemoGateway 是 2 个独立的实体,那么为什么会出现这样的错误?
谢谢
【问题讨论】:
标签: scala inheritance akka-http