标签:apach str keep tle update version rip xml文件 ast
最近在学习消息总线Kafka的时候,在IDEA中写了一个简单的生产者和消费者demo。但是消费者端一直报错。错误信息如下:
1 ConsumerIterator<byte[],byte[]> it =stream.iterator(); 2 这句代码老是报错,The method iterator() is ambiguous for the type KafkaStream<byte[],byte[]>
后来博主在网上找了一些资料,解决方法记录一下:
poom.xml文件如下:
1 <dependencies> 2 <dependency> 3 <groupId>org.apache.kafka</groupId> 4 <artifactId>kafka_2.9.2</artifactId> 5 <version>0.8.1.1</version> 6 <exclusions> 7 <exclusion> 8 <artifactId>jmxtools</artifactId> 9 <groupId>com.sun.jdmk</groupId> 10 </exclusion> 11 <exclusion> 12 <artifactId>jmxri</artifactId> 13 <groupId>com.sun.jmx</groupId> 14 </exclusion> 15 <exclusion> 16 <artifactId>jms</artifactId> 17 <groupId>javax.jms</groupId> 18 </exclusion> 19 <exclusion> 20 <groupId>org.apache.zookeeper</groupId> 21 <artifactId>zookeeper</artifactId> 22 </exclusion> 23 <exclusion> 24 <groupId>org.slf4j</groupId> 25 <artifactId>slf4j-log4j12</artifactId> 26 </exclusion> 27 <exclusion> 28 <groupId>org.slf4j</groupId> 29 <artifactId>slf4j-api</artifactId> 30 </exclusion> 31 </exclusions> 32 </dependency> 33 </dependencies> 34 35 <build> 36 <plugins> 37 <plugin> 38 <artifactId>maven-assembly-plugin</artifactId> 39 <configuration> 40 <descriptorRefs> 41 <descriptorRef>jar-with-dependencies</descriptorRef> 42 </descriptorRefs> 43 <archive> 44 <manifest> 45 <mainClass></mainClass> 46 </manifest> 47 </archive> 48 </configuration> 49 <executions> 50 <execution> 51 <id>make-assembly</id> 52 <phase>package</phase> 53 <goals> 54 <goal>single</goal> 55 </goals> 56 </execution> 57 </executions> 58 </plugin> 59 <!--<plugin>--> 60 <!--<groupId>org.apache.maven.plugins</groupId>--> 61 <!--<artifactId>maven-compiler-plugin</artifactId>--> 62 <!--<version>3.1</version>--> 63 <!--<configuration>--> 64 <!--<source>1.8</source>--> 65 <!--<target>1.8</target>--> 66 <!--<showWarnings>true</showWarnings>--> 67 <!--</configuration>--> 68 <!--</plugin>--> 69 </plugins> 70 </build>
首先将maven中的poom.xml文件中以下内容注释掉:
1 <plugin> 2 <groupId>org.apache.maven.plugins</groupId> 3 <artifactId>maven-compiler-plugin</artifactId> 4 <version>3.1</version> 5 <configuration> 6 <source>${jdk.version}</source> 7 <target>${jdk.version}</target> 8 <showWarnings>true</showWarnings> 9 </configuration> 10 </plugin>
然后在自己的IDEA MAVEN项目中配置默认jdk版本:
配置方法如下:
第一种:在maven的安装目录找到settings.xml文件,在里面添加如下代码
1 <profile> 2 <id>jdk-1.8</id> 3 <activation> 4 <activeByDefault>true</activeByDefault> 5 <jdk>1.8</jdk> 6 </activation> 7 <properties> 8 <maven.compiler.source>1.8</maven.compiler.source> 9 <maven.compiler.target>1.8</maven.compiler.target> 10 <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> 11 </properties> 12 </profile>
添加完后,在对IDEA进行设置。file->setting->maven->user settings file,user settings file那里选择maven安装目录下的settings.xml文件.
第二种方法是在第一种的基础之上:user settings的默认settigs.xml文件路径为:C:\Users\Administrator\.m2。只要把设置好的settings.xml文件复制到该目录下,然后update project就好了。
The method iterator() is ambiguous for the type KafkaStream
标签:apach str keep tle update version rip xml文件 ast
原文地址:https://www.cnblogs.com/gemine/p/9065087.html