大家好,我两次遇到这个难题,但我被封锁了... 即:当我建立我的jar文件并尝试在我的实例ec2中运行它时,我遇到了这个问题,我与maven都有所有依赖关系,但仍然有这个问题... 有任何想法或帮助!!
Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/OkHttpClient
at com.ACList.Foundry2.Connectivity2.App.<init>(App.java:10)
at com.ACList.Foundry2.Connectivity2.App.main(App.java:30)
Caused by: java.lang.ClassNotFoundException: okhttp3.OkHttpClient
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more
答案 0 :(得分:0)
我终于找到了解决方案。更改了构建参数后,我就可以获取具有所有依赖项的完整jar
如果有人遇到相同的问题,这是我pom.xml的版本
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.ACList.Foundry2.Connectivity2.App</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>