IDEA里运行代码时出现Error:scalac: error while loading JUnit4, Scala signature JUnit4 has wrong version expe...

本文解决了一个Scala项目中因版本不匹配导致的编译错误问题,包括错误信息详解及快速解决方案,通过注释或删除不匹配的测试类实现。同时提供了更深入的配置调整建议。

 

 

   不多说,直接上干货!

 

  

 问题详情

  当出现这类错误时是由于版本不匹配造成的

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

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值