前言
小编我将用CSDN记录软件开发求学之路上亲身所得与所学的心得与知识,有兴趣的小伙伴可以关注一下!
也许一个人独行,可以走的很快,但是一群人结伴而行,才能走的更远!让我们在成长的道路上互相学习,让我们共同进步,欢迎关注!
小编最近使用Spring做单元测试时,通过导入junit和spring-test.jar来做测试,控制台出现以下警告,并不会影响运行结果:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/C:/Users/kiki/.m2/repository/org/springframework/spring-core/4.3.17.RELEASE/spring-core-4.3.17.RELEASE.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1 WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
pom.xml文件中小编引入的是4.3.17的版本:
因此小编后来将spring-test的版本改为5.3.1就可以了
下面是关于如何引入Spring单元测试模块简单描述一下:
1:maven引入这两个依赖包: junit spring-test
2:单元测试 运行器 @RunWith(SpringJUnit4ClassRunner.class)
3:单元测试 加载配置文@ContextConfiguration(classes=AppConfig.class)