如下,build中的内容换成自己的:
<build> <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <archive> <manifest> <!--这里要替换成jar包main方法所在类 --> <mainClass>com.rokid.logAnalysis.LogAnalysis</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <!-- this is used for inheritance merges --> <phase>package</phase> <!-- 指定在打包节点执行jar包合并操作 --> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
maven install之后 target目录中会有两个jar包
logAnalysis-0.0.1-SNAPSHOT-jar-with-dependencies.jar
logAnalysis-0.0.1-SNAPSHOT.jar
参考自:http://www.cnblogs.com/bobsha/p/5698090.html