• Java: 创建自带依赖库的Jar包


    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>com.shinefriends.gateway</groupId>
        <artifactId>gateway</artifactId>
        <version>1.0</version>
    
        <dependencies>
            <dependency>
                <groupId>org.nanohttpd</groupId> <!-- <groupId>com.nanohttpd</groupId> for 2.1.0 and earlier -->
                <artifactId>nanohttpd</artifactId>
                <version>2.2.0</version>
            </dependency>
    
            <dependency>
                <groupId>com.mashape.unirest</groupId>
                <artifactId>unirest-java</artifactId>
                <version>1.4.9</version>
            </dependency>
        </dependencies>
    
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifest>
                                <mainClass>com.shinefriends.gateway.App</mainClass>
                            </manifest>
                        </archive>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>

    随后输入打包命令:

    mvn clean compile assembly:single

    这时在target目录下就会生成对应的Jar包文件了。

  • 相关阅读:
    大数据学习之路(持续更新中...)
    数据挖掘之初级
    用户画像
    机器挖掘之经典算法
    算法时间复杂度
    01-IOS-越狱指南
    gradle 内容学习参考
    python 获取文件路径相关
    第一行代码阅读笔记
    使用同步锁防止多进程的并发操作
  • 原文地址:https://www.cnblogs.com/ilovewindy/p/10823497.html
Copyright © 2020-2023  润新知