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

 

 



本文转自大数据躺过的坑博客园博客,原文链接:http://www.cnblogs.com/zlslch/p/7446548.html,如需转载请自行联系原作者

相关文章
|
Java
使用IDEA创建项目运行我的第一个JAVA文件输出Helloword
本文介绍了如何使用IDEA(IntelliJ IDEA)创建一个新的Java项目,并运行一个简单的Java程序输出"Hello Word"。文章详细展示了创建项目的步骤,包括选择JDK版本、设置项目名称和路径、创建包和类,以及编写和运行代码。最后,还展示了如何通过IDEA的运行功能来执行程序并查看输出结果。
2104 4
使用IDEA创建项目运行我的第一个JAVA文件输出Helloword
|
Java Maven 容器
Maven使用IDEA自带工具打包,同时将lib下的jar包打入,双击jar包可直接运行
使用IntelliJ IDEA的Artifacts功能,可以将项目依赖的第三方jar包打包进jar文件中,实现双击jar包即可直接运行。
Maven使用IDEA自带工具打包,同时将lib下的jar包打入,双击jar包可直接运行
|
SQL 前端开发 Java
在IDEA中使用Maven将SpringBoot项目打成jar包、同时运行打成的jar包(前后端项目分离)
这篇文章介绍了如何在IntelliJ IDEA中使用Maven将Spring Boot项目打包成可运行的jar包,并提供了运行jar包的方法。同时,还讨论了如何解决jar包冲突问题,并提供了在IDEA中同时启动Vue前端项目和Spring Boot后端项目的步骤。
在IDEA中使用Maven将SpringBoot项目打成jar包、同时运行打成的jar包(前后端项目分离)
IDEA运行 支付宝案例
该博客文章提供了在IntelliJ IDEA中运行支付宝案例的指南,并分享了项目源码的GitHub地址以及使用说明。
|
人工智能 Java 测试技术
Spring Boot 集成 JUnit 单元测试
本文介绍了在Spring Boot中使用JUnit 5进行单元测试的常用方法与技巧,包括添加依赖、编写测试类、使用@SpringBootTest参数、自动装配测试模块(如JSON、MVC、WebFlux、JDBC等),以及@MockBean和@SpyBean的应用。内容实用,适合Java开发者参考学习。
1708 0
|
Java 测试技术 数据库连接
【SpringBoot(四)】还不懂文件上传?JUnit使用?本文带你了解SpringBoot的文件上传、异常处理、组件注入等知识!并且带你领悟JUnit单元测试的使用!
Spring专栏第四章,本文带你上手 SpringBoot 的文件上传、异常处理、组件注入等功能 并且为你演示Junit5的基础上手体验
1336 3
|
XML Java 测试技术
Spring5入门到实战------17、Spring5新功能 --Nullable注解和函数式注册对象。整合JUnit5单元测试框架
这篇文章介绍了Spring5框架的三个新特性:支持@Nullable注解以明确方法返回、参数和属性值可以为空;引入函数式风格的GenericApplicationContext进行对象注册和管理;以及如何整合JUnit5进行单元测试,同时讨论了JUnit4与JUnit5的整合方法,并提出了关于配置文件加载的疑问。
Spring5入门到实战------17、Spring5新功能 --Nullable注解和函数式注册对象。整合JUnit5单元测试框架
|
Java 测试技术 Android开发
课时148:junit测试工具
课时148介绍了JUnit测试工具的使用,包括定义、配置和编写测试程序。JUnit是流行的用例测试工具,用于确保代码稳定性。
515 21
|
Java 程序员 测试技术
Java|让 JUnit4 测试类自动注入 logger 和被测 Service
本文介绍如何通过自定义 IDEA 的 JUnit4 Test Class 模板,实现生成测试类时自动注入 logger 和被测 Service。
419 5
|
SQL JavaScript 前端开发
基于Java访问Hive的JUnit5测试代码实现
根据《用Java、Python来开发Hive应用》一文,建立了使用Java、来开发Hive应用的方法,产生的代码如下
529 6