maven-assembly-plugin打包可执行的jar包

pom.xml添加

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.spark.service.SparkStreamingKafka</mainClass>
                <!--project 入口->
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<!-- <goal>assembly</goal> -->
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!--use commend: mvn assembly:assembly -DskipTests -->
</plugins>
</build>
mvn clean package                      //可生成***-jar-with-dependencies.jar与***.jar,前者即为可执行jar包

mvn clean compile assembly:single      //可生成***-jar-with-dependencies.jar,即为可执行jar包
上一篇:43. Multiply Strings (JAVA)


下一篇:[Java] Collections - 源代码学习笔记