[英]Eclipse Maven dependency cannot be resolved to a type
Maven project dependencies are added and jars are downloaded also classes could be seen but in code it is saying "KafkaConsumer cannot be resolved to a type". 添加了Maven项目依赖项并下载了jar,还可以看到类,但是在代码中说“ KafkaConsumer无法解析为类型”。 I restarted the Eclipse.Did clean the project.
我重启了Eclipse,清理了项目。 Maven update project is done.But no option is working.
Maven更新项目已完成。但是没有任何选择。 Below is the image from the eclipse.
下面是日食的图像。
Eclipse: 日食:
Eclipse Java EE IDE for Web Developers.
Version: Neon.3 Release (4.6.3)
Build id: 20170314-1500
pom.xml 的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Apache.Kafka</groupId>
<artifactId>Apache.Kafka</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Apache.Kafka</name>
<properties>
<java.version>1.8</java.version>
<jdk.version>1.8</jdk.version>
<jre.version>1.8</jre.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.10.1.0</version>
</dependency>
</dependencies>
</project>
This one worked for me in a project I did a few months ago. 这个是我几个月前做的一个项目,为我工作。
I added all imports I needed, not the wildcard 我添加了我需要的所有导入,而不是通配符
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
//Here you define the props and topics
KafkaConsumer<String, byte[]> consumer = new KafkaConsumer<String, byte[]>(props);
And I was using this other version: 我正在使用其他版本:
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.9.0.1</version>
</dependency>
However I suspect the problem is not in the dependency version. 但是我怀疑问题不在依赖版本中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.