1、问题描述: springboot调用@test单元测试报错。java.lang.NoSuchMethodError: org.junit.platform.commons.util.ReflectionUtils.getDefaultClassLoader()Ljava/lang/ClassLoader
2、问题分析:springboot2.x 默认是用 Junit5来执行的,但是Idea2016版本过低,不支持Junit5。官网明确指出在IntelliJ IDEA 中使用Junit5 时,需要Idea2017.3版本之后,之前的版本不支持 JUnit5.
3、问题解决:
解决方案一:将IDEA升级到2017.3之后的版本,则升级IDEA
解决方案二:使用 JUnit4(很麻烦,有博主试了有用,我自己操作了一上午,没法用)
使用JUnit4参考: http://blog.itblood.com/1926.html
https://my.oschina.net/u/3439389/blog/4656147
4、总结:最好的解决办法是下载idea2017.3版本之后