저는 스칼라 전문가가 아닙니다. Vert.x에서 간단한 예제 Verticle을 실행하고 싶습니다. 내가 Vert.x에이 코드를 실행하면Vert.x에서 스칼라 컴파일 오류가 발생했습니다.
class ScalaServer extends Verticle {
override def start() {
vertx.setPeriodic(1000, { timerId: Long =>
vertx.eventBus.publish("news-feed", "News from Scala")
})
}
}
는 그러나 컴파일러는 다음과 같은 메시지와 함께 불평 : 어쩌면 바로 오류를보고 거기에 누군가가
error: type mismatch;
found : scala.Long => org.vertx.java.core.eventbus.EventBus
required: org.vertx.java.core.Handler[java.lang.Long]
vertx.setPeriodic(1000, { timerId: Long =>
^
입니다.
스칼라의 SAM 합성 지원 (java 8 스타일 람다)을 사용하려고합니까? 컴파일러에'-Xexperimental'을 건네 줄 필요가 있습니다.'timerId'를'java.lang.Long'으로 입력해야 할 수도 있습니다. ('Long'은'scala.Long'을 의미하며 java' long'와 같습니다.). – lmm