Spark错误:NoSuchMethodError:scala.Predef $。$ conforms()Lscala / Predef $$ less $ colon $ less

时间:2017-06-05 16:16:41

标签: java scala maven apache-spark

我有一个提交Twitter帖子的应用程序。 它工作正常,但在修改构建路径后,我没有设置它之前的状态。我一直收到这个错误:

Exception in thread "main" java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;
at org.apache.spark.util.Utils$.getSystemProperties(Utils.scala:1710)
at org.apache.spark.SparkConf.loadFromSystemProperties(SparkConf.scala:73)
at org.apache.spark.SparkConf.<init>(SparkConf.scala:68)
at org.apache.spark.SparkConf.<init>(SparkConf.scala:55)
at Analytics.init(Analytics.java:20)
at KafkaTwitterProducer.main(KafkaTwitterProducer.java:162)

这是我的pom.xml

&#13;
&#13;
<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>TwitterStreamingAnalyzer</groupId>
  <artifactId>TwitterStreamingAnalyzer</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
   <dependency>  
                <groupId>org.apache.kafka</groupId>  
                <artifactId>kafka_2.10</artifactId>  
                <version>0.10.2.1</version>  
           </dependency>  
           <!-- https://mvnrepository.com/artifact/org.twitter4j/twitter4j-core -->  
           <dependency>  
                <groupId>org.twitter4j</groupId>  
                <artifactId>twitter4j-core</artifactId>  
                <version>4.0.4</version>  
           </dependency>  
           <!-- https://mvnrepository.com/artifact/org.twitter4j/twitter4j-stream -->  
           <dependency>  
                <groupId>org.twitter4j</groupId>  
                <artifactId>twitter4j-stream</artifactId>  
                <version>4.0.4</version>  
           </dependency>  
           <!-- https://mvnrepository.com/artifact/org.twitter4j/twitter4j-async -->  
           <dependency>  
                <groupId>org.twitter4j</groupId>  
                <artifactId>twitter4j-async</artifactId>  
                <version>4.0.4</version>  
           </dependency> 
           
     </dependencies> 
</project>
&#13;
&#13;
&#13;

我已经阅读了所有类似的问题,但没有一个能帮助我,因为我试图导入正确版本的罐子,但它仍然无法运作。 我该如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

看起来你正在尝试在其他版本(可能是2.11)中编译的Spark集群中使用Scala 2.10中编译的kafka库。在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>TwitterStreamingAnalyzer</groupId>
  <artifactId>TwitterStreamingAnalyzer</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
   <dependency>  
                <groupId>org.apache.kafka</groupId>  
                <artifactId>kafka_2.11</artifactId>  
                <version>0.10.2.1</version>  
           </dependency>  
           <!-- https://mvnrepository.com/artifact/org.twitter4j/twitter4j-core -->  
           <dependency>  
                <groupId>org.twitter4j</groupId>  
                <artifactId>twitter4j-core</artifactId>  
                <version>4.0.4</version>  
           </dependency>  
           <!-- https://mvnrepository.com/artifact/org.twitter4j/twitter4j-stream -->  
           <dependency>  
                <groupId>org.twitter4j</groupId>  
                <artifactId>twitter4j-stream</artifactId>  
                <version>4.0.4</version>  
           </dependency>  
           <!-- https://mvnrepository.com/artifact/org.twitter4j/twitter4j-async -->  
           <dependency>  
                <groupId>org.twitter4j</groupId>  
                <artifactId>twitter4j-async</artifactId>  
                <version>4.0.4</version>  
           </dependency> 

     </dependencies> 
</project>