Scala Error: error while loading Suite, Scala signature Suite has wrong version expected: 5.0 found:

準備給scala項目引入單元測試java

<dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.10</artifactId>
      <version>2.2.6</version>
</dependency>

 

Scala版本: 2.10.4

 

編譯的時候遇到了下面的錯誤:服務器

Error:scalac: error while loading Suite, Scala signature Suite has wrong version  expected: 5.0  found: 4.1 in Suite.class

 

一開始猜錯是scalatest的版本不對,換了幾個版本都仍是遇到同樣的錯誤,認真閱讀錯誤信息後恍然大悟!app

應該是編譯環境的版本不對,我原來安裝的scala版本是2.10.4,升級到1.11.7後沒有這個錯誤了,但卻出現了另一個錯誤:less

can't expand macros compiled by previous versions of Scala

意思應該是說不能展開之前版本scala編譯的宏單元測試

 

把相應的scalatest編譯的版本升級一下:scalatest_2.10 -> scalatest_2.11測試

 

最終的配置:

<dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.11</artifactId>
      <version>2.2.6</version>
      <scope>test</scope>
</dependency>
Scala版本: 2.11.7

 

用2.11.7版本的scala編譯沒有問題了,可是在提交到spark運行的過程當中發現有錯誤,個人spark用的是官方的基於scala2.10.4編譯的2.5.1。ui

java.lang.NoSuchMethodError: scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;

 

若是想要要用2.11.7版本的scala來編譯你的spark app的話spa

在服務器上就必須本身用對應版本scala從新編譯spark!!!scala

爲了偷懶繼續折騰~code

把scala SDK降級到2.10.6,並把scalatest降級到相應的版本

 

最最終的配置:

<dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.10</artifactId>
      <version>2.2.6</version>
      <scope>test</scope>
</dependency>

 

Scala版本: 2.10.6

 

最後,終於能夠正常編譯和運行scalatest了,而且編譯的二進制能夠在spark上運行起來了。

相關文章
相關標籤/搜索