IDEA报错:No hostname could be resolved for the IP address 127.0.0.1, using IP address as host name.

 idea编辑flink连接kafka读取数据时报错:

No hostname could be resolved for the IP address 127.0.0.1, using IP address as host name. Local input split assignment (such as for HDFS files) may be impacted.

kafka正常,该怎么解决?????

package test

  import org.apache.flink.api.common.serialization.SimpleStringSchema
  import org.apache.flink.streaming.api.scala._
  import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer
  import java.util.Properties

object task {

  //fink采集kafka数据,分析写入redis
  def main(args: Array[String]): Unit = {
    //  创建运行环境
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1) //设置并行度
    //封装访问kafka集群的配置
    val prop = new Properties()
      prop.setProperty("bootstrap.servers", "master:9092")
    prop.setProperty("group.id", "order-group")

    //将kafka作为数据源添加进env
    //      SimpleStringSchema,是因为kafka是纯字节存储,所以需要在代码中进行反序列化成对象,让Scala可以解析

    val stream = env.addSource(new FlinkKafkaConsumer[String]("order", new SimpleStringSchema(), prop))
    stream.print()
    env.execute()

  }
}

 报错:

C:\Users\Dell\.jdks\corretto-1.8.0_372\bin\java.exe "-javaagent:D:\zxy\IntelliJ IDEA Community Edition 2023.1.3\lib\idea_rt.jar=49820:D:\zxy\IntelliJ IDEA Community Edition 2023.1.3\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\Dell\AppData\Local\Temp\classpath1711515240.jar test.task
2023-07-12 19:41:33,481 WARN [org.apache.flink.runtime.webmonitor.WebMonitorUtils] - Log file environment variable 'log.file' is not set.
2023-07-12 19:41:33,481 WARN [org.apache.flink.runtime.webmonitor.WebMonitorUtils] - JobManager log files are unavailable in the web dashboard. Log file location not found in environment variable 'log.file' or configuration key 'web.log.path'.
2023-07-12 19:41:35,146 WARN [org.apache.flink.runtime.taskmanager.Task] - Source: Custom Source -> Sink: Print to Std. Out (1/1)#0 (a8eadfe10e64678882479a27fb34f604) switched from RUNNING to FAILED with failure cause: java.lang.NoSuchMethodError: org.apache.flink.api.common.functions.RuntimeContext.getMetricGroup()Lorg/apache/flink/metrics/MetricGroup;
	at org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumerBase.run(FlinkKafkaConsumerBase.java:705)
	at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:116)
	at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:73)
	at org.apache.flink.streaming.runtime.tasks.SourceStreamTask$LegacySourceFunctionThread.run(SourceStreamTask.java:323)

2023-07-12 19:41:35,187 WARN [org.apache.flink.runtime.taskmanager.TaskManagerLocation] - No hostname could be resolved for the IP address 127.0.0.1, using IP address as host name. Local input split assignment (such as for HDFS files) may be impacted.
Exception in thread "main" org.apache.flink.runtime.client.JobExecutionException: Job execution failed.
	at org.apache.flink.runtime.jobmaster.JobResult.toJobExecutionResult(JobResult.java:144)
	at 

进程已结束,退出代码1

你可能感兴趣的:(flink,kafka,idea)