如何使用包含签名的jar依赖项的maven构建单个可运行的jar?

时间:2018-08-30 08:55:04

标签: java maven

我在这里找到了一些帖子,人们在其中展示了如何制作一个包含其依赖项jar的可运行jar。但是,当我尝试执行此操作时,出现签名的jar错误。我如何才能将其与充气城堡配合使用?

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <mainClass>${one-jar-main-class}</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>attached</goal>
                    </goals>
                    <phase>package</phase>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <mainClass>${one-jar-main-class}</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    </build>

我第二次尝试这样做,但是现在我收到了这个错误。

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: com/netsuite/webservices/platform_2017_1/NetSuiteServiceLocator
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
    at java.lang.Class.getMethod0(Class.java:3018)
    at java.lang.Class.getMethod(Class.java:1784)
    at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: com.netsuite.webservices.platform_2017_1.NetSuiteServiceLocator
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

当前构建设置

            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                    <executions>
                        <execution>
                            <phase>process-sources</phase>

                            <goals>
                                <goal>copy-dependencies</goal>
                            </goals>

                            <configuration>
                            <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
                              <!--   <outputDirectory>${project.build.directory}/dependency</outputDirectory>-->

                            </configuration>
                        </execution>
                    </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                <archive>
                    <manifest>
                    <classpathPrefix>lib/</classpathPrefix>
                    <mainClass>${one-jar-main-class}</mainClass>
                        <addClasspath>true</addClasspath>
                    </manifest>
                </archive>
                </configuration>
            </plugin>

0 个答案:

没有答案