无法运行从Maven Shade插件创建的jar文件

时间:2019-12-10 21:48:08

标签: java eclipse maven maven-shade-plugin

当我尝试运行jar文件时,没有任何反应。当我尝试使用命令通过命令运行它时,也没有任何错误

java -jar ".\target\DApi-0.0.1-SNAPSHOT-shaded.jar"

我的主要人员位于这里:

。\ target \ DApi-0.0.1-SNAPSHOT-shaded.jar \ com \ q \ maven \ DApi \ GUI.class

当我打开罐子时,我还可以看到我正在使用的依赖项的所有文件夹。我尝试过使用其他方式通过Eclipse构建它,但是在运行它时仍然遇到相同的问题,但没有任何反应。该项目在Eclipse内部运行良好。

以下是我在pom文件中的构建:

<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>3.2.1</version>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
        <configuration>
          <transformers>
            <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
              <mainClass>com.q.maven.DApi.GUI</mainClass>
            </transformer>
          </transformers>
          <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
        </configuration>
      </execution>
    </executions>
  </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.5.1</version>
        <configuration>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
</plugins>
</build>

我的主:

    public static void main(String[] args) {

    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                GUI window = new GUI();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

0 个答案:

没有答案