1. 程式人生 > 其它 >maven-dependency-plugin maven-assembly-plugin

maven-dependency-plugin maven-assembly-plugin

Maven3種打包方式之一maven-assembly-plugin的使用

https://blog.csdn.net/qq_32736999/article/details/93395246

maven打包之assembly和shade對比

https://blog.csdn.net/Cool0/article/details/107625828

idea打jar包(包括依賴包)

https://blog.csdn.net/sinat_37064286/article/details/99293688

<?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>org.example</groupId> <artifactId>ClickhouseJdbc</artifactId> <version>
1.0-SNAPSHOT</version> <name>ClickhouseJdbc</name> <!-- FIXME change it to the project's website --> <url>http://www.example.com</url> <properties> <build.number>SNAPSHOT</build.number> <java.version>1.8</java.version> <!--
${project.version} could not used for project dependencies due to some modules have their own version number --> <project.reporting.outputEncoding>utf-8</project.reporting.outputEncoding> <project.build.sourceEncoding>utf-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>ru.yandex.clickhouse</groupId> <artifactId>clickhouse-jdbc</artifactId> <version>0.3.1</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> <plugin> <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>org.example.App</mainClass> </manifest> </archive> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <id>copy</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory> ${project.build.directory}/lib </outputDirectory> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.3.0</version> <configuration> <appendAssemblyId>false</appendAssemblyId> <finalName>test</finalName> <descriptorRefs> <!-- 將依賴的jar包中的class檔案打進生成的jar包--> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <addClasspath>true</addClasspath> <!-- 有Main函式的類:為了生成的jar包使用命令執行時的入口函式,可靈活增加活刪除--> <mainClass>org.example.App</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>