1 仅架包
架包定义:指仅将代码打包到jar中,在运行的平台必须保证依赖。
方法:maven —> Lifecyle —> Clean —> Package
2 架包与全包(推荐)
全包定义:将maven项目中的依赖于代码都打为一个包。
方法:maven —> Plugins —> assembly —>assembly:assembly
项目配置
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>groupId</groupId>
<artifactId>azkaban_cs</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<!-- 引入打包插件 -->
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- <dependencies>-->
<!-- <!–Lombok –>-->
<!-- <dependency>-->
<!-- <groupId>org.projectlombok</groupId>-->
<!-- <artifactId>lombok</artifactId>-->
<!-- </dependency>-->
<!-- </dependencies>-->
</project>
新建主目录文件:assembly.xml
<assembly xmlns:xsi="" xmlns="" xsi:schemaLocation=" ">
<id>${project.version}</id>
<formats>
<format>dir</format>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<baseDirectory>${build.directory}</baseDirectory>
<fileSets>
<fileSet>
<directory>conf/</directory>
<outputDirectory>${project.artifactId}/conf</outputDirectory>
</fileSet>
<fileSet>
<directory>db/</directory>
<outputDirectory>${project.artifactId}/db</outputDirectory>
</fileSet>
<fileSet>
<directory>${build.directory}</directory>
<includes>
<include>*.jar</include>
</includes>
<excludes>
<exclude>*sources.jar</exclude>
</excludes>
<outputDirectory>${project.artifactId}/lib</outputDirectory>
</fileSet>
<fileSet>
<directory>bin/</directory>
<outputDirectory>${project.artifactId}/bin</outputDirectory>
<fileMode>754</fileMode>
<lineEnding>unix</lineEnding>
</fileSet>
</fileSets>
</assembly>
开始打包
加粗样式