简体   繁体   English

如果目标文件夹不存在,NoClassDefFoundError on Maven 依赖

[英]NoClassDefFoundError on Maven dependency if target folder is not present

Currently my NetBeans 8.0 has been doing the strangest thing.目前我的 NetBeans 8.0 一直在做最奇怪的事情。

I have a multimodule project.我有一个多模块项目。 Usually I did not even have to have the projects opened or even downloaded, if the modules were in maven repository.通常我什至不必打开甚至下载项目,如果模块在 maven 存储库中。 Currently, some of my modules however need to be opened and built, so that "target" folder is in the project directory filled with classes.目前,我的一些模块需要打开和构建,因此“目标”文件夹位于充满类的项目目录中。 If it is not, I get a NoClassDefFoundError.如果不是,我会得到一个 NoClassDefFoundError。

The error looks like this:错误如下所示:

Exception in thread "main" java.lang.NoClassDefFoundError: SOME/CLASS/THAT/IS/EXPECTED/IN/TARGET/FOLDER/OF/SOME/MODULE/THAT/IS/A/DEPENDENCY
at ...
Caused by: java.lang.ClassNotFoundException: com.example.SOME.CLASS.THAT.IS.EXPECTED.IN.TARGET.FOLDER.OF.SOME.MODULE.THAT.IS.A.DEPENDENCY
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 2 more

My POM looks like this:我的 POM 看起来像这样:

<parent>
    <groupId>some</groupId>
    <artifactId>parent</artifactId>
    <version>0.9-SNAPSHOT</version>
</parent>

<scm>
    <developerConnection>scm:svn:https://someconnection</developerConnection>
</scm>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
                <tagBase>sometagbase/tags</tagBase>
            </configuration>
        </plugin> 
    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
    </dependency>
    <dependency>
        <groupId>myModuleGroupId</groupId>
        <artifactId>somModule1</artifactId>
        <version>1.2.1-SNAPSHOT</version>
        <type>jar</type>
    </dependency>
      ...... many of these here
</dependencies>

Why does it suddenly require a target folder with classes?为什么它突然需要一个带有类的目标文件夹? Is it not supposed to get them from the dependencies?难道不应该从依赖项中获取它们吗? From the repository?从存储库?

Open maven tab at right side of the editor and run double click all options of life cycle and try to see if folder finally generated打开编辑器右侧的maven选项卡,运行双击生命周期的所有选项,尝试查看文件夹是否最终生成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM