参考文献:http://blog.csdn.net/xiao__gui/article/details/47341385
方法:使用assembly插件,生成的jar包名为xxx-jar-with-dependencies
- 指定mainClass会把主类写到MANIFEST.MF文件里
- 指定jar-with-dependencies会把依赖考到jar包里。
1 <build>View Code
2 <plugins>
3 <plugin>
4 <groupId>org.apache.maven.plugins</groupId>
5 <artifactId>maven-assembly-plugin</artifactId>
6 <version>2.2.2</version>
7 <configuration>
8 <archive>
9 <manifest>
10 <addClasspath>true</addClasspath>
11 <mainClass>your main class</mainClass>
12 </manifest>
13 </archive>
14 <descriptorRefs>
15 <descriptorRef>jar-with-dependencies</descriptorRef>
16 </descriptorRefs>
17 </configuration>
18 <executions>
19 <execution>
20 <id>make-assembly</id>
21 <phase>package</phase>
22 <goals>
23 <goal>single</goal>
24 </goals>
25 </execution>
26 </executions>
27 </plugin>
28 </plugins>
29 </build>