如何让一个简单的maven项目支持one-jar 做成一个jar fatjar
2017-01-18 15:13
447 查看
<?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>yourGoupid</groupId> <artifactId>yourArtifactId</artifactId> <version>1.0-SNAPSHOT</version> <build> <plugins> <!-- Includes the runtime dependencies --> <plugin> <groupId>com.jolira</groupId> <artifactId>onejar-maven-plugin</artifactId> <version>1.4.4</version> <executions> <execution> <goals> <goal>one-jar</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>yourMainClass</mainClass> </manifest> </archive> </configuration> </plugin> </plugins> </build> </project>
为了让一个简单的java程序,可以用java -jar yourJar.jar arg1 arg2 的形式方便的执行,通过one-jar-maven-plugin 插件可以打包成一个jar,另外为了指定Main-Class,还需要使用maven-jar-plugin指定 Main-Class。
参考 http://one-jar.sourceforge.net/
One-JAR lets you package a Java application together with its dependency Jars into a single executable Jar file.
相关文章推荐
- hibernate向mysql数据库插入中文显示??
- struts2注解路径问题
- gcc降级
- jQuery Jcrop 图像裁剪
- ibatis开发入门
- Linux设备驱动之字符设备驱动
- equals hashCode
- 摄像头驱动之实现数据传输3_设置参数_学习笔记
- Binary search (4) -- Find Right Interval,Count Complete Tree Nodes,Divide Two Integers
- OID-----利用SNMP获取、走访节点值【程序代码+分析
- hive异常MetaException-Metastore contains multiple versions
- PHP最常用的正则表达式,让你少写1000行代码
- CAMERA学习(二)--------HAL
- PPP与PPTP
- Codeforces 755-D. PolandBall and Polygon(树状数组+计算几何)
- 通过查看mysql 配置参数、状态来优化你的mysql
- vb获得网络时间的函数(历史上最全最完整最可靠的函数)
- 配置Tensorlayer的时候安装出现unable to find vcvarsall.bat
- 扩展卡尔曼滤波(EKF)仿真
- 后缀数组,LCP(Stammering Aliens,LA 4513)