从Spring3迁移到Spring4测试报错

在老的项目中使用的是Spring3.2,最近我使用了Spring4.0.6进行迁移测试,之前使用的mock的测试没有问题,但是在Spring4中报错如下:

java.lang.NoSuchMethodError: org.springframework.core.CollectionFactory.createLinkedMapIfPossible(I)Ljava/util/Map;
	at org.springframework.mock.web.MockHttpServletRequest.<init>(MockHttpServletRequest.java:107)
	at org.springframework.mock.web.MockHttpServletRequest.<init>(MockHttpServletRequest.java:187)
	at com.baidu.solr.finance.IncrementalContorllerTest.init(IncrementalContorllerTest.java:28)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.junit.internal.runners.MethodRoadie.runBefores(MethodRoadie.java:129)
	at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:93)
	at org.unitils.UnitilsJUnit4TestClassRunner$TestListenerInvokingMethodRoadie.runBeforesThenTestThenAfters(UnitilsJUnit4TestClassRunner.java:186)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
	at org.unitils.UnitilsJUnit4TestClassRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java:95)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61)
	at org.unitils.UnitilsJUnit4TestClassRunner.access$000(UnitilsJUnit4TestClassRunner.java:42)
	at org.unitils.UnitilsJUnit4TestClassRunner$1.run(UnitilsJUnit4TestClassRunner.java:60)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
	at org.unitils.UnitilsJUnit4TestClassRunner.run(UnitilsJUnit4TestClassRunner.java:67)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

我查看了一下代码和pom.xml的依赖关系,之前Spring3的依赖如下:

<properties>
        <spring.version>3.2.4.RELEASE</spring.version>
        <junit.version>4.10</junit.version>
    </properties>
...
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-mock</artifactId>
            <version>2.0.8</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

到了Spring4,就需要把spring-mock依赖去除。

希望可以帮助到诸位!

时间: 2024-10-08 12:25:00

从Spring3迁移到Spring4测试报错的相关文章

apache ab压力测试报错apr_socket_recv

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104)) apache 自带的ab工具测试,当并发量达到1000多的时候报错如下: [[email protected] ~]# ab -n 100000 -c 1000 http://192.168.2.170/index.htmlThis is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Ada

真机测试报错ERROR/AndroidRuntime: java.lang.RuntimeException: setParameters failed解决办法

这个错误是和调用相机摄像头相关的. 产生这个错误的原因主要在于代码控制分辨率的显示和真机测试分辨率不一样. 一:解决办法 WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Camera.Parameters parameters = camera.getParameters();// 得到摄像头的参数 para

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104))

apache ab压力测试报错(apr_socket_recv: Connection reset by peer (104)) 今天用apache 自带的ab工具测试,当并发量达到1000多的时候报错如下: [[email protected]~]# This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech

hyper-v迁移vm的时候报错?

hyper-v""迁移""vm的时候报错,如果"共享存储""没有问题的话,多半是""hyper-v管理器""的""虚拟机交换机管理器""中的""虚拟网络交换机""的名字不一样导致的:

hivesql 迁移spark3.0 sparksql报错如Cannot safely cast &#39;字段&#39;:StringType to IntegerType的问题

一 问题 hivesql可以正常运行,spark3.0运行报错如图 spark3.0配置 查看源码新增一个 val STORE_ASSIGNMENT_POLICY = buildConf("spark.sql.storeAssignmentPolicy") .doc("When inserting a value into a column with different data type, Spark will perform " + "type coe

使用apache benchmark(ab) 测试报错汇总

1.socket: Too many open files (24) 解决方法: [[email protected] ~]# ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 14802 max locked memory (kby

Spring项目JUnit测试报错ClassNotFoundException解决、

MyEclipse项目上有红色感叹号,各包显示正常.用JUnit测试部分能运行,部分报错,报错如下: Class not found n_jdbc.UserDaoTestjava.lang.ClassNotFoundException: n_jdbc.UserDaoTest at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native

ab压力测试报错: apr_socket_recv: Connection reset by peer (104)

使用ab对网站进行压力测试,开始设置并发500,可以正常使用,当设置并发为1000,则报错: apr_socket_recv: Connection reset by peer (104) 改服务端apache的maxclients参数,调大最大打开文件数,都不解决问题,最后才发现是因为ab的源码对ab的并发有限制,修改源码重新编译apache: 修改源码support目录下的ab.c文件,大概在1369行,修改为: return;} else {//apr_err("apr_socket_re

jmeter压力测试报错:java.net.BindException: Address already in use: connect解决办法

最近在用jmeter做压力测试时,发现一个问题,当线程持续上升到某个值时,报错:java.net.BindException: Address already in use: connect,如下图所示: 原因:windows提供给TCP/IP链接的端口为 1024-5000,并且要四分钟来循环回收它们,就导致我们在短时间内跑大量的请求时将端口占满了,导致如上报错. 解决办法(在jmeter所在服务器操作): 1.cmd中输入regedit命令打开注册表: 2.在 HKEY_LOCAL_MACH