Nosuchmethoderror Chinese means that there is no method found, the error is not to say that the dependent jar package, method does not exist and cannot be found, which is similar to the classnotfoundexception error, The classnotfoundexception error is not necessarily a lack of dependent jar, class, it is possible to rely on the conflict, that is, the jar that quoted multiple error class.
So again, Nosuchmethoderror appears often because of the error of this method of the class jar package created a conflict.
After understanding why this error occurred, we resolved the error. In general, manually introducing a jar package (ie, a non-dependent management tool), remove the duplicate jar package directly and OK.
Our key point is how to solve this problem in the MAVEN project.
It's time to raise a chestnut:
For example, a Spring Boot project that was previously done, there was a place in the process where the Ali Dubbo jar package was used to introduce a dependency
<DEPENDENCY>
<groupId> Com.alibaba</groupid>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
</DEPENDENCY>
Span style= "font-size:13px" to cause the project to fail to start with the error:
Exception in thread "main" JAVA.LANG.NOSUCHMETHODERROR:ORG.SPRINGF Ramework.core.annotation.
Annotationawareordercomparator.sort (ljava/util/list;) V
Ctrl + Left-click into Dubbo this dependency, find Dubbo also need to rely on spring, and the s in my project Pring version is not the same, so there is a conflict,
the way to solve this is to let Dubbo rely on the spring no longer added to the project dependencies, as follows:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
</exclusion>
</exclusions>
</dependency>
This will allow the project to start running normally.
The general solution of Java.lang.NoSuchMethodError