值创建不是对象org.apache.kafka.clients.admin.KafkaAdminClient的成员

时间:2019-04-27 16:01:13

标签: scala

我正试图在Scala中按以下方式使用KafkaAdminClient.create

import java.util.Properties

import org.apache.kafka.clients.admin.KafkaAdminClient


final class DetectorActor extends TemplateActor {

  val props = new Properties
  props.put("bootstrap.servers", "localhost:9092")
  props.put("connections.max.idle.ms", "10000")
  props.put("request.timeout.ms", "5000")

  val adminClient = {
    val client = KafkaAdminClient.create(props)

  }

  override def receive: Receive = ???
}

,它不起作用,因为Scala编译器找不到KafkaAdminClient.create(props)工厂方法。

value create is not a member of object org.apache.kafka.clients.admin.KafkaAdminClient
[error]     val client = KafkaAdminClient.create(props)

我在做什么错了?

1 个答案:

答案 0 :(得分:1)

dfs <- ls(envir=env)[sapply(mget(ls(envir=env), env), is.data.frame)] 扩展了org.apache.kafka.clients.admin.KafkaAdminClient

后者具有静态方法org.apache.kafka.clients.admin.AdminClient

create(props: Properties): AdminClient

val client = AdminClient.create(props) 的scaladoc说

KafkaAdminClient

https://www.programcreek.com/java-api-examples/index.php?api=org.apache.kafka.clients.admin.AdminClient