java.lang.NoClassDefFoundError

编程入门 行业动态 更新时间:2024-10-27 20:29:12
本文介绍了java.lang.NoClassDefFoundError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这里是我编译项目时得到的

Here what i got when compile the project

通过这个命令

mvn compile exec:java -Dexec.classPathScope=compile -Dexec.mainClass=trident.myproject

得到这个

java.lang.NoClassDefFoundError: storm/trident/state/StateFactory at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) at java.lang.Class.getMethod0(Class.java:2670) at java.lang.Class.getMethod(Class.java:1603) at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.ClassNotFoundException: storm.trident.state.StateFactory at java.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 6 more INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] An exception occured while executing the Java class. storm/trident /state/StateFactory storm.trident.state.StateFactory

我查看了文件夹,但找不到这个类!虽然我之前成功运行过

i reviewed the folder and can't find this class ! although i ran it before successfully

我把pom文件写成部分

i wrote pom file as parts

<dependencies> <dependency> <groupId>storm</groupId> <artifactId>storm</artifactId> <version>0.8.2</version> <scope>provided</scope> </dependency>

pom.xml 的第 2 部分

part 2 of pom.xml

<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>colt</groupId> <artifactId>colt</artifactId> <version>1.2.0</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.0.0</version> </dependency>

pom.xml 的第 3 部分

part 3 of pom.xml

<dependency> <groupId>org.twitter4j</groupId> <artifactId>twitter4j-core</artifactId> <version>4.0.2</version> </dependency> <dependency> <groupId>org.twitter4j</groupId> <artifactId>twitter4j-stream</artifactId> <version>4.0.2</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency> </dependencies>

推荐答案

您可能已经更改了 pom.xml 文件中依赖项的范围.如果您的容器提供了对所提供的依赖项更改范围.提供

You might have changed the scope of the dependency in your pom.xml file. If your container is providing the dependency change scope to provided. <scope>provided</scope>

如果容器未提供要编译的依赖项更改范围.编译

If container is not providing the dependency change scope to compile. <scope>compile</scope>

更多推荐

java.lang.NoClassDefFoundError

本文发布于:2023-05-31 10:02:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/389509.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:java   lang   NoClassDefFoundError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!