|
Today met a java.lang.NoSuchMethodException exception. The basic idea is to solve:
1, check the class where the jar package version is correct.
2, check if there are jar package conflicts, such as loading multiple versions of xxx.jar.
If the project is a maven, you can mvn dependency: tree to display the project dependency tree.
3. If you can not locate, through the following methods to find the actual project loaded class belongs jar package.
1 Class< ?> clazz = Class.forName ( "com.xxx.xxx.XXX"); # class name
2 CodeSource cs = clazz.getProtectionDomain () getCodeSource ().;
3 String location = cs.getLocation () getPath ().;
4 System.out.println (location);
The above code did not take exception handling, add their own.
Through the above method to determine the actual loading of the class is in line with expectations, to do the processing. |
|
|
|