我有一个带有 main
)在eclipse中运行得很好,但是当我将它导出到一个(打包的)可运行jar并尝试使用 java -jar
我收到以下错误消息:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:61)
Caused by: java.lang.NoClassDefFoundError: com/github/javafaker/Faker
at jultävlingar2020.Jultävlingar2020.useChrome(Jultävlingar2020.java:154)
at jultävlingar2020.Jultävlingar2020.main(Jultävlingar2020.java:57)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.github.javafaker.Faker
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:435)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 7 more
似乎有一个问题,包括 javafaker
但是在eclipse中使用它可以很好地工作。
这个项目是基于gradle和我的 Project and External dependencies
-我的文件夹 javafaker-1.0.2.jar
.
我的build.gradle看起来像这样:
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:28.2-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
// Selenium
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.141.59'
// Javafaker
implementation 'com.github.javafaker:javafaker:1.0.2'
}
我该怎么解决这个问题?
暂无答案!
目前还没有任何答案,快来回答吧!