pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>dbOperate.DBMain</mainClass> //默认的主程序入口
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
打包命令 mvn package (加clean貌似会报错)
生成一个jar: test-1.0-SNAPSHOT.jar
运行方式:java -jar test-1.0-SNAPSHOT.jar 是执行默认的主程序,即dbOperate.DBMain
在项目中我还有一个main函数,matchDatasClean.MatchDataClean,若要执行它,
可以: java -cp test-1.0-SNAPSHOT.jar matchDatasClean.MatchDataClean