我在 pom.xml 中为 cdk 添加了 maven 依赖项,但在执行 jar 文件时仍然出现一个找不到类的错误。
dyna218-128:spark4vs laeeqahmed$ java -cp target/spark4vs-1.0-SNAPSHOT.jar se.uu.farmbio.spark4vs.RunPrediction
Exception in thread "main" java.lang.NoClassDefFoundError: org/openscience/cdk/interfaces/IAtomContainer
Caused by: java.lang.ClassNotFoundException: org.openscience.cdk.interfaces.IAtomContainer
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
POM.XML 如下
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency><!-- SVM depedency -->
<groupId>tw.edu.ntu.csie</groupId>
<artifactId>libsvm</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.openscience.cdk</groupId>
<artifactId>cdk</artifactId>
<version>1.4.7</version>
</dependency>
<repositories>
<repository>
<id>3rdparty</id>
<url>https://maven.ch.cam.ac.uk/content/repositories/thirdparty/</url>
</repository>
</repositories>