Maven如何打包本地依赖包
2016-01-20 10:37
323 查看
有的jar包,在maven中心库里面是没有的,那么,如何在项目中使用呢?
假设我们需要使用:apache-ant-zip-2.3.jar
将该jar包,放在项目的lib目录,例如:
在pom.xml里面增加该jar的引用,例如:
<dependency>
<groupId>org.apache</groupId>
<artifactId>apache-ant-zip</artifactId>
<version>2.3</version>
<scope>system</scope>
<systemPath>${basedir}/lib/apache-ant-zip-2.3.jar</systemPath>
</dependency>
这样就可以在项目中使用apache-ant-zip-2.3.jar了!
这里有个问题,在项目打包成war的时候,如何将apache-ant-zip-2.3.jar包含在内呢?
其实在pom.xml里面做个配置即可,例如:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>${project.artifactId}</warName>
<webResources>
<resource>
<directory>lib/</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
当然在include里面,也是可以打包其他的文件的,诸如xml,properties等配置文件。
打包以后,发现apache-ant-zip-2.3.jar果然已经在war包里面。
大功告成!
花间一壶酒,独酌无相亲。 举杯邀明月,对影成三人。 木头大哥所发的文章均基于自身实践,各位江湖好汉可以通过:hellowood23@163.com 联系之。
假设我们需要使用:apache-ant-zip-2.3.jar
将该jar包,放在项目的lib目录,例如:
在pom.xml里面增加该jar的引用,例如:
<dependency>
<groupId>org.apache</groupId>
<artifactId>apache-ant-zip</artifactId>
<version>2.3</version>
<scope>system</scope>
<systemPath>${basedir}/lib/apache-ant-zip-2.3.jar</systemPath>
</dependency>
这样就可以在项目中使用apache-ant-zip-2.3.jar了!
这里有个问题,在项目打包成war的时候,如何将apache-ant-zip-2.3.jar包含在内呢?
其实在pom.xml里面做个配置即可,例如:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>${project.artifactId}</warName>
<webResources>
<resource>
<directory>lib/</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
当然在include里面,也是可以打包其他的文件的,诸如xml,properties等配置文件。
打包以后,发现apache-ant-zip-2.3.jar果然已经在war包里面。
大功告成!
花间一壶酒,独酌无相亲。 举杯邀明月,对影成三人。 木头大哥所发的文章均基于自身实践,各位江湖好汉可以通过:hellowood23@163.com 联系之。
相关文章推荐
- TCP拥塞控制
- HDU 1078 FatMouse and Cheese
- CodeIgniter多语言实现方法详解
- webrtc agc
- iOS -字符串替换 富文本的简单使用
- C3p0配置Mysql失效
- (一)、认识 hadoop
- selector状态
- Android47_传感器Sensor
- 细述Web技术与Native App共存的这10年
- 使用System.arraycopy()实现数组之间的复制
- js-RSA加密解密
- Spring注解详解
- Android 利用 aapt 解析 apk 得到应用名称 包名 版本号 权限等信息
- nova cell配置
- pycurl 使用 跳转
- XSD文件详解
- iOS新浪微博 微信好友、微信朋友圈、QQ自身sdk分享方法
- error C2065: “SurfFeatureDetector”: 未声明的标识符
- linux select 多路复用机制