java.lang.NoClassDefFoundError

java.lang.NoClassDefFoundError

这是我编译项目时得到的结果

通过这个命令

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.run(ExecJavaMojo.java:285)
at java.lang.Thread.run(Thread.java:662)
 Caused by: java.lang.ClassNotFoundException: storm.trident.state.StateFactory
at java.net.URLClassLoader.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 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

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

我把 pom 文件写成部分

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

第 2 部分 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>

第 3 部分 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 文件中更改了依赖项的范围。如果您的容器正在提供依赖更改范围以提供。
<scope>provided</scope>

如果容器未提供要编译的依赖项更改范围。
<scope>compile</scope>