A recent project introduced MongoDB, finished the code, started the service, JUnit Unit test ran, error:
Java.lang.noclassdeffounderror:org/springframework/core/defaultparameternamediscoverer
At Org.springframework.data.mapping.model.preferredconstructordiscoverer.<clinit> ( PREFERREDCONSTRUCTORDISCOVERER.JAVA:38)
At Org.springframework.data.mapping.model.basicpersistententity.<init> (basicpersistententity.java:90)
At Org.springframework.data.mongodb.core.mapping.basicmongopersistententity.<init> ( BASICMONGOPERSISTENTENTITY.JAVA:67)
At Org.springframework.data.mongodb.core.mapping.MongoMappingContext.createPersistentEntity ( mongomappingcontext.java:89)
At Org.springframework.data.mongodb.core.mapping.MongoMappingContext.createPersistentEntity ( MONGOMAPPINGCONTEXT.JAVA:37)
At Org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity ( abstractmappingcontext.java:279)
At Org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity ( abstractmappingcontext.java:180)
At Org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity ( abstractmappingcontext.java:140)
At Org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity ( ABSTRACTMAPPINGCONTEXT.JAVA:67)
At Org.springframework.data.mongodb.core.MongoTemplate.assertUpdateableIdIfNotSet (mongotemplate.java:1138)
At Org.springframework.data.mongodb.core.MongoTemplate.doInsert (mongotemplate.java:708)
At Org.springframework.data.mongodb.core.MongoTemplate.insert (mongotemplate.java:672)
At Com.isz.app.baseDao.MongodbBaseDao.insert (mongodbbasedao.java:250)
At Com.isz.app.push.mapper.impl.PushMessageTaskMapperImpl.insertPushMessageTask (Pushmessagetaskmapperimpl.java : 64)
At Com.isz.app.push.biz.PushServiceBiz.insertPushMessageTask (pushservicebiz.java:136)
At Com.isz.app.push.biz.PushServiceBiz.singlePush (pushservicebiz.java:44)
At Com.isz.app.push.service.impl.PushServiceFacade.singlePush (pushservicefacade.java:22)
At Com.isz.app.push.service.impl.PushServiceFacadeTest.test1 (pushservicefacadetest.java:31)
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.runners.model.frameworkmethod$1.runreflectivecall (frameworkmethod.java:47)
At Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:12)
At org.junit.runners.model.FrameworkMethod.invokeExplosively (frameworkmethod.java:44)
At Org.junit.internal.runners.statements.InvokeMethod.evaluate (invokemethod.java:17)
At Org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate ( runbeforetestmethodcallbacks.java:74)
At Org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate ( RUNAFTERTESTMETHODCALLBACKS.JAVA:83)
At Org.springframework.test.context.junit4.statements.SpringRepeat.evaluate (springrepeat.java:72)
At Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (springjunit4classrunner.java:231)
At Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild (springjunit4classrunner.java:88)
At Org.junit.runners.parentrunner$3.run (parentrunner.java:238)
At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:63)
At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:236)
At org.junit.runners.parentrunner.access$000 (parentrunner.java:53)
At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:229)
At Org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate ( RUNBEFORETESTCLASSCALLBACKS.JAVA:61)
At Org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate ( RUNAFTERTESTCLASSCALLBACKS.JAVA:71)
At Org.junit.runners.ParentRunner.run (parentrunner.java:309)
At Org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run (springjunit4classrunner.java:174)
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:459)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:675)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:382)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:192)
caused By:java.lang.ClassNotFoundException:org.springframework.core.DefaultParameterNameDiscoverer
At Java.net.urlclassloader$1.run (urlclassloader.java:366)
At Java.net.urlclassloader$1.run (urlclassloader.java:355)
At java.security.AccessController.doPrivileged (Native Method)
At Java.net.URLClassLoader.findClass (urlclassloader.java:354)
At Java.lang.ClassLoader.loadClass (classloader.java:425)
At Sun.misc.launcher$appclassloader.loadclass (launcher.java:308)
At Java.lang.ClassLoader.loadClass (classloader.java:358)
... More
See ClassNotFoundException (Note the difference between classnotfoundexception and Noclassdeffounderror), Mainly because org.springframework.core.DefaultParameterNameDiscoverer this class cannot be found, the following begins the analysis process:
1. First look at the next item in the Spring-core Jar pack is the 3.2.4.release version, open the source code, indeed there is no defaultparameternamediscoverer this class
2. Determine which spring jar package in MongoDB conflicts with spring's jar package in my project now
3.debug Step-by-step find where the error is (the style of the spring code as long as it is a specific implementation class with Do), in the new Preferredconstructordiscoverer this class when the error, open this class, according to the error message, 38 lines of this class:
4. Defaultparameternamediscoverer is really used here, and the jar package for this class is, Spring-data-commons-1.9.3-releas version, Description 1.9. Version 3 and 3.2.4core are incompatible, 1.9.3 version is to correspond to spring-core-4.0.0.0 above (downloaded 4.0 of the core source code, there is Defaultparameternamediscoverer this class)
5. Now to determine how this project introduced the Spring-data-commons-1.9.3-releas jar package, this time using a Maven dependency tree command Mvn:dependency:tree, This command can be used to view all dependencies of the entire project
This is a primary dependency, removed, then view the project dependency tree, the original 1.9.3 dependency has been removed, now with the 1.8.2 jar package
6. Start the project, OK, run perfectly.
Resolve Maven Jar Package conflicts