IDEA里運行代碼時出現Error:scalac: error while loading JUnit4, Scala signature JUnit4 has wrong version expected: 5.0 found: 4.1 in JUnit4.class錯誤的解決辦法(圖文詳解)


 

 

   不多說,直接上干貨!

 

  

 問題詳情

  當出現這類錯誤時是由於版本不匹配造成的

Information:2017/8/29 7:54 - Compilation completed with 10 errors and 0 warnings in 3s 910ms
Error:scalac: error while loading JUnit4, Scala signature JUnit4 has wrong version
 expected: 5.0
 found: 4.1 in JUnit4.class
Error:scalac: error while loading ConsoleRunner, Scala signature ConsoleRunner has wrong version
 expected: 5.0
 found: 4.1 in ConsoleRunner.class
Error:scalac: error while loading Specification, Scala signature Specification has wrong version
 expected: 5.0
 found: 4.1 in Specification.class
D:\Code\IntelliJIDEACode\HadoopSparkMllibAction\src\test\scala\zhouls\bigdata\MySpec.scala
Error:(6, 26) illegal inheritance;
 self-type zhouls.bigdata.MySpecTest does not conform to org.specs.runner.JUnit4's selftype org.specs.runner.JUnit4
class MySpecTest extends JUnit4(MySpec)
                         ^
Error:(6, 18) org.specs.runner.JUnit4 does not have a constructor
class MySpecTest extends JUnit4(MySpec)
                 ^
Error:(8, 29) illegal inheritance;
 self-type zhouls.bigdata.MySpecRunner.type does not conform to org.specs.runner.ConsoleRunner's selftype org.specs.runner.ConsoleRunner
object MySpecRunner extends ConsoleRunner(MySpec)
                            ^
Error:(8, 21) org.specs.runner.ConsoleRunner does not have a constructor
object MySpecRunner extends ConsoleRunner(MySpec)
                    ^
Error:(10, 23) illegal inheritance;
 self-type zhouls.bigdata.MySpec.type does not conform to org.specs.Specification's selftype org.specs.Specification
object MySpec extends Specification {
                      ^
Error:(10, 15) org.specs.Specification does not have a constructor
object MySpec extends Specification {
              ^
Error:(11, 27) value should is not a member of String
  "This wonderful system" should {
                          ^

 

 

 

 

 

 

 

解決辦法

  如果你想快速運行的話,就用idea建立的maven項目生成的幾個test類和對象注釋掉,或者刪除掉即可運行。

 

 

 

   然后,運行即可。

 

 

  當然,上面的這種方法不是最徹底的。

   File  -> settings ->  Editor -> plugins -> junit

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM