无法 运行 具有 httpclient 依赖性的 maven jar

Not able to run the maven jar with httpclient dependency

使用 maven 创建了 jar 文件,当我尝试执行 java -jar 出现以下异常时:

Error: A JNI error has occurred, please check your installation and try again
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpUriRequest
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)

请帮我解决这个问题。

确保 HttpUriRequest 在你的罐子里。您很可能需要使用 Maven shade or assembly 插件创建可执行 jar。