使用assembly将maven项目pom.xml中的jar包打包
来源:互联网 发布:js 检测分辨率 编辑:程序博客网 时间:2024/06/06 14:07
方法一:将pom.xml引入的jar包打到zip文件夹中
1、pom.xml的配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!-- 打包配置 start -->
<
build
>
<
plugins
>
<
plugin
>
<!-- NOTE: We don't need a groupId specification because the group is
org.apache.maven.plugins ...which is assumed by default. -->
<
artifactId
>maven-assembly-plugin</
artifactId
>
<
version
>2.4</
version
>
<
configuration
>
<
descriptors
>
<
descriptor
>src/main/assembly/src.xml</
descriptor
>
</
descriptors
>
<
descriptorRefs
>
<
descriptorRef
>jar-with-dependencies</
descriptorRef
>
</
descriptorRefs
>
</
configuration
>
<
executions
>
<
execution
>
<
id
>make-assembly</
id
>
<!-- this is used for inheritance merges -->
<
phase
>package</
phase
>
<!-- bind to the packaging phase -->
<
goals
>
<
goal
>single</
goal
>
</
goals
>
</
execution
>
</
executions
>
</
plugin
>
</
plugins
>
</
build
>
2、src.xml文件内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<
assembly
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/assembly-1.0.0.xsd">
<
id
>package</
id
>
<
formats
>
<
format
>zip</
format
>
</
formats
>
<
includeBaseDirectory
>true</
includeBaseDirectory
>
<
fileSets
>
<
fileSet
>
<
directory
>src/main/bin</
directory
>
<
outputDirectory
>/</
outputDirectory
>
</
fileSet
>
<
fileSet
>
<
directory
>src/main/config</
directory
>
<
outputDirectory
>config</
outputDirectory
>
</
fileSet
>
</
fileSets
>
<
dependencySets
>
<
dependencySet
>
<
outputDirectory
>lib</
outputDirectory
>
<
scope
>runtime</
scope
>
</
dependencySet
>
</
dependencySets
>
</
assembly
>
方法1能把所有引入的包打成jar包,方便自己保存和引入。
3、最后一步:
cmd进入在项目根目录下,键入“mvn package”,OK完事!
方法二:将pom引入的jar包打进你的项目工程jar包内
1、pom.xml的配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!-- 打包配置 start -->
<
build
>
<!-- <finalName>im-dal-service</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
控制资源文件的拷贝
<resource>
<directory>src/main/resources</directory>
<targetPath>${project.build.directory}</targetPath>
</resource>
</resources> -->
<
plugins
>
<
plugin
>
<
artifactId
>maven-assembly-plugin</
artifactId
>
<
configuration
>
<
descriptors
>
<
descriptor
>src/main/assembly/src.xml</
descriptor
>
</
descriptors
>
</
configuration
>
</
plugin
>
</
plugins
>
</
build
>
2、src.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?
xml
version="1.0" encoding="UTF-8"?>
<
assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<
id
>jar-with-dependencies</
id
>
<
formats
>
<
format
>jar</
format
>
</
formats
>
<
includeBaseDirectory
>false</
includeBaseDirectory
>
<
dependencySets
>
<
dependencySet
>
<
unpack
>false</
unpack
>
<
scope
>runtime</
scope
>
</
dependencySet
>
</
dependencySets
>
<
fileSets
>
<
fileSet
>
<
directory
>/lib</
directory
>
</
fileSet
>
</
fileSets
>
</
assembly
>
3、最后一步:
cmd进入在项目根目录下,键入“mvn assembly:assembly”完事!
转载地址:http://www.cnblogs.com/enshrineZither/p/3402616.html
0 0
- 使用assembly将maven项目pom.xml中的jar包打包
- 使用assembly将maven项目pom.xml中的jar包打包
- 使用assembly将maven项目pom.xml中的jar包打包
- 使用assembly将maven项目pom.xml中的jar包打包
- 使用maven的maven-assembly-plugin将jar包依赖打包到一个jar文件中
- 使用maven的maven-assembly-plugin将jar包依赖打包到一个jar文件
- Maven将本地jar包生成pom文件,在项目中引用打包到本地仓库。
- maven打包的时候 ,将依赖包 打进同一个jar包命令 mvn assembly:assembly -DskipTests
- 使用Maven Assembly plugin将依赖打包进jar
- 使用Maven Assembly plugin将依赖打包进jar
- 怎么发布一个pom项目且打包maven源码,将源码包与jar包一同deploy到mavenserver
- maven项目 pom.xml中添加jar包
- Maven 打包 jar 、war 文件时,不将 pom.xml 等打包进包中
- Maven 打包 jar 、war 文件时,不将 pom.xml 等打包进包中
- 使用mvn assembly:assembly打包会出现找不到非maven管理的jar中的类
- 使用maven将项目打成jar包
- 利用assembly.xml,打包maven项目
- 构建工具-Maven-使用maven-assembly-plugin将依赖打包进jar并指定JDK版本
- hadoop 学习笔记:mapreduce框架详解
- 正式赛-ZZULIOJ-1881-蛤玮的机房(并查集)
- 严重: StandardServer.await: create[localhost:8005]
- bzoj 3329: Xorequ 数位dp
- HDU 1157 Who's in the Middle(排序取中间值)
- 使用assembly将maven项目pom.xml中的jar包打包
- Android Hal层简要分析
- CommonJS、AMD和CMD规范
- poj2377 最大生成树 Kruskal
- HTML5第8次课堂笔记( 模拟form表单提交数据,xml的解析,jQuery的Ajax方法使用, mui的ajax)
- Java加密技术(一)——BASE64与单向加密算法MD5&SHA&MAC
- Jenkins入门系列
- sql server触发器
- Gradle DSL method not found: 'runProguard()'