错误内容如下:
log4j:WARN No appenders could be found for logger (org.springframework.test.context.junit4.SpringJUnit4ClassRunner).
log4j:WARN Please initialize the log4j system properly.
上面只是警告貌似没问题,最关键是下面这串需要求助
java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.getAnnotationAttributes(Ljava/lang/annotation/Annotation;ZZ)Lorg/springframework/core/annotation/AnnotationAttributes;
at org.springframework.core.annotation.AnnotatedElementUtils$4.process(AnnotatedElementUtils.java:94)
at org.springframework.core.annotation.AnnotatedElementUtils$4.process(AnnotatedElementUtils.java:91)
at org.springframework.core.annotation.AnnotatedElementUtils.doProcess(AnnotatedElementUtils.java:161)
at org.springframework.core.annotation.AnnotatedElementUtils.process(AnnotatedElementUtils.java:152)
at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:91)
at org.springframework.core.annotation.AnnotatedElementUtils.getAnnotationAttributes(AnnotatedElementUtils.java:84)
at org.springframework.test.context.MetaAnnotationUtils$AnnotationDescriptor.<init>(MetaAnnotationUtils.java:269)
at org.springframework.test.context.MetaAnnotationUtils$AnnotationDescriptor.<init>(MetaAnnotationUtils.java:257)
at org.springframework.test.context.MetaAnnotationUtils.findAnnotationDescriptor(MetaAnnotationUtils.java:102)
at org.springframework.test.context.MetaAnnotationUtils.findAnnotationDescriptor(MetaAnnotationUtils.java:116)
at org.springframework.test.context.TestContextManager.retrieveTestExecutionListeners(TestContextManager.java:182)
at org.springframework.test.context.TestContextManager.<init>(TestContextManager.java:120)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTestContextManager(SpringJUnit4ClassRunner.java:120)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<init>(SpringJUnit4ClassRunner.java:109)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
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)
2 个解决方案
#1
getAnnotationAttributes方法在4.0签名变了,和3.0不一样,所以统一用3.0或者用4.0就OK
你肯定同时导入了3.0和4.0了,或者曾经都导过但没删掉以前导的东西
如果你用maven就清空重导入,没用maven就用统一spring版本
你肯定同时导入了3.0和4.0了,或者曾经都导过但没删掉以前导的东西
如果你用maven就清空重导入,没用maven就用统一spring版本
#2
NoSuchMethodError 你是不是少 jar 或者jar 冲突。
#1
getAnnotationAttributes方法在4.0签名变了,和3.0不一样,所以统一用3.0或者用4.0就OK
你肯定同时导入了3.0和4.0了,或者曾经都导过但没删掉以前导的东西
如果你用maven就清空重导入,没用maven就用统一spring版本
你肯定同时导入了3.0和4.0了,或者曾经都导过但没删掉以前导的东西
如果你用maven就清空重导入,没用maven就用统一spring版本
#2
NoSuchMethodError 你是不是少 jar 或者jar 冲突。