简体   繁体   English

mvn jar文件:库包含失败

[英]mvn jar file : library include failed

I did mvn package and ran my file by doing java -jar target\\output.jar 我做了mvn package并通过java -jar target\\output.jar运行我的文件

All the jar libraries specified in the dependency of pom.xml are not included. 不包括在pom.xml的依赖项中指定的所有jar库。 Do advice what's wrong below. 请在下面提出建议。 Thanks! 谢谢!

Below is my pom.xml to allow jar file generation. 下面是我的pom.xml,允许生成jar文件。

    <plugin>
        <!-- Build an executable JAR -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.1.0</version>
            <configuration>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>com.workspez.psg.letrikEtara.PlanetGroupLetrikEtara</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

Try and compare/complete your declaration with the ones in " Including dependencies in a jar with Maven ", like adding the executions section. 尝试与“ 使用Maven包含jar中的依赖关系”中的声明进行比较/完成声明,例如添加executions部分。

Or, if this is not working, consider the maven shade plugin , whic can achieve a simlar goal. 或者,如果这不起作用,请考虑maven shade插件 ,它可以实现一个类似的目标。

Got it working. 搞定了。 This was missing: 这个缺失了:

<descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs>

To the following should work: 以下应该工作:

        <plugin>
            <!-- Build an executable JAR -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>3.1.0</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <addClasspath>true</addClasspath>
                        <classpathPrefix>lib/</classpathPrefix>
                        <mainClass>com.workspez.psg.letrikEtara.PlanetGroupLetrikEtara</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>

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

相关问题 构建jar并包含库jar - Build jar and include library jar Android库:在可分发的JAR文件中包含属性文件 - Android Library : Include properties file within a distributable JAR file 将 JAXB 的库包含到 JAR 文件中,而不使用 Maven - Include library for JAXB into JAR file without using Maven Android,如何在不是JAR文件的项目中包含特定库? - Android, How to include specific library in project that is not a JAR file? Maven - 在jar中包含引用的库 - Maven - include referenced library in jar Maven Shade 插件:“mvn install”如何在本地存储库中包含通过“mvn package”生成的相同 jar? - Maven Shade Plugin: how 'mvn install' can include in the local repository the same jar generated through 'mvn package'? 如何将库包含到我的JAR并将属性文件移到该JAR之外?(MAVEN) - How can include library to my JAR and move property file to outside this JAR?(MAVEN) 使用mvn assembly:single建立具有依赖关系的jar时,如何包含本地jar? - How do you include a local jar when using mvn assembly:single to build a jar-with-dependencies? mvn exec:java在外部JAR文件中运行java文件 - mvn exec:java to run a java file in an external JAR file 包含一个Jar文件的属性文件 - Include A Properties File With A Jar File
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM