zoukankan      html  css  js  c++  java
  • 如何让一个简单的maven项目支持one-jar 做成一个jar fatjar

    <?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>yourGoupid</groupId>
        <artifactId>yourArtifactId</artifactId>
        <version>1.0-SNAPSHOT</version>
        <build>
            <plugins>
                <!-- Includes the runtime dependencies -->
                <plugin>
                    <groupId>com.jolira</groupId>
                    <artifactId>onejar-maven-plugin</artifactId>
                    <version>1.4.4</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>one-jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.4</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                                <classpathPrefix>lib/</classpathPrefix>
                                <mainClass>yourMainClass</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
            </plugins>
        </build>
        
    </project>

    为了让一个简单的java程序,可以用java -jar yourJar.jar arg1 arg2 的形式方便的执行,通过one-jar-maven-plugin 插件可以打包成一个jar,另外为了指定Main-Class,还需要使用maven-jar-plugin指定 Main-Class。

    参考 http://one-jar.sourceforge.net/

    One-JAR lets you package a Java application together with its dependency Jars into a single executable Jar file.

  • 相关阅读:
    用 .Net WebBrowser 控件获取POST数据
    yield再理解--绝对够透彻
    Keras 和 PyTorch 的对比选择
    Keras -Python编写的开源人工神经网络库
    Python 加密之 生成pyd文件
    FPN全解-特征金字塔网络
    RetinaNet(Focal Loss)
    Focal Loss for Dense Object Detection(Retina Net)
    ImageNet Classification-darknet
    Darknet
  • 原文地址:https://www.cnblogs.com/geektown/p/6296839.html
Copyright © 2011-2022 走看看