简体   繁体   English

使用Maven和Intellij Designer的Java中的NoClassDefFoundError

[英]NoClassDefFoundError in Java, using maven and Intellij Designer

When I try to run my application with maven from the terminal, I get a NoClassDefFoundError in main thread. 当我尝试从终端使用Maven运行应用程序时,在主线程中收到NoClassDefFoundError。 I have used IntelliJ GUI Designer. 我已经使用了IntelliJ GUI Designer。 When I run using IntelliJ it runs fine. 当我使用IntelliJ运行时,它运行良好。 But when I run from the terminal theses errors pop up. 但是,当我从终端运行时,这些错误会弹出。

Exception in thread "main" java.lang.NoClassDefFoundError: com/intellij/uiDesigner/core/GridLayoutManager
                at za.co.##.swingy.view.Start.$$$setupUI$$$(Start.java)
                at za.co.##.swingy.view.Start.<init>(Start.java:34)
                at za.co.##.swingy.view.Gui.GuiView.run(GuiView.java:10)
                at za.co.##.swingy.Swingy.main(Swingy.java:26)
     Caused by: java.lang.ClassNotFoundException: com.intellij.uiDesigner.core.GridLayoutManager
                at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
                at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
                at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

This is my pom.xml 这是我的pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 `http://maven.apache.org/xsd/maven-4.0.0.xsd">`
    <modelVersion>4.0.0</modelVersion>

    <groupId>#####</groupId>
    <artifactId>swingy</artifactId>
    <version>1</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>7</source>
                    <target>7</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>ideauidesigner-maven-plugin</artifactId>
                <version>1.0-beta-1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>javac2</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <fork>true</fork>
                    <debug>true</debug>
                    <failOnError>true</failOnError>
                </configuration>

            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>XLSCreator</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.12.6</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator-annotation-processor</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.15</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.15</version>
        </dependency>

        <dependency>
            <groupId>com.intellij</groupId>
            <artifactId>forms_rt</artifactId>
            <version>7.0.3</version>
        </dependency>

        <dependency>
            <groupId>org.swinglabs</groupId>
            <artifactId>swingx</artifactId>
            <version>1.6.1</version>
        </dependency>

    </dependencies>

I have done some research and I think I have all of the plugins and dependencies. 我做了一些研究,我认为我拥有所有的插件和依赖项。 Am I missing Something? 我想念什么吗?

You can try adding the 您可以尝试添加

<goal>copy-dependencies</goal>

Reference : https://maven.apache.org/plugins/maven-dependency-plugin/examples/copying-project-dependencies.html 参考: https : //maven.apache.org/plugins/maven-dependency-plugin/examples/copying-project-dependencies.html

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>3.1.1</version>
  <executions>
    <execution>
      <id>copy-dependencies</id>
      <phase>package</phase>
      <goals>
        <goal>copy-dependencies</goal>
      </goals>
      <configuration>
        <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
        <overWriteReleases>false</overWriteReleases>
        <overWriteSnapshots>false</overWriteSnapshots>
        <overWriteIfNewer>true</overWriteIfNewer>
      </configuration>
    </execution>
  </executions>
</plugin>

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

相关问题 java.lang.NoClassDefFoundError 与 Intellij 和 Maven - java.lang.NoClassDefFoundError with Intellij And Maven IntelliJ - Maven 添加外部 jar 文件但 java.lang.NoClassDefFoundError - IntelliJ - Maven adding external jar file but java.lang.NoClassDefFoundError Java EE:使用IntelliJ和Maven的NoClassDefFoundError org.joda.time.DateTime - Java EE: NoClassDefFoundError org.joda.time.DateTime with IntelliJ and Maven 使用JPA,JavaFX和Maven,出现NoClassDefFoundError错误:javax / persistence / Persistence Intellij - Using JPA, JavaFX and Maven, error of NoClassDefFoundError: javax/persistence/Persistence Intellij IntelliJ idea gui 设计师 + maven - IntelliJ idea gui designer + maven 使用Maven时出现Java.lang.NoClassDefFoundError - Java.lang.NoClassDefFoundError when using Maven 使用Maven在Java项目中运行时出现NoClassDefFoundError - NoClassDefFoundError at runtime in java project using maven Java:Maven项目中的NoClassDefFoundError? - Java: NoClassDefFoundError in maven project? 使用Gradle的IntelliJ插件给出java.lang.NoClassDefFoundError - IntelliJ Plugin using Gradle gives java.lang.NoClassDefFoundError 在IntelliJ中使用MongoDB驱动程序时出现java.lang.NoClassDefFoundError - java.lang.NoClassDefFoundError when using MongoDB driver in intellij
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM