Home > Back-end >  Dynamic loading of the jar is not an error in the getMethod also did not return
Dynamic loading of the jar is not an error in the getMethod also did not return

Time:12-23

String filePath="test. The jar";
The File File=new File (filePath);
URL the URL=file. ToURI (.) toURL ();
URLClassLoader loader=new URLClassLoader (new [URL] {URL});
String className="com. My. Test".

Class<?> ProcessorClass=loader. LoadClass (className);
The Object obj=processorClass. NewInstance ();
Method=processorClass. GetMethod (" getData ", String class, BodyBuf. Class)
Method. The invoke (obj, "12345", buf);

When you perform to processorClass. The getMethod stopped, that there is no return, no exception,

Test. The jar is external packages, as well as MVN packaging, in the development environment test normal call, after using MVN packaged in running environment according to the above phenomenon in a log,
  • Related