maven打包插件配置

一、maven打包可执行jar文件,需要引入插件

<plugin>
	<artifactId>maven-assembly-plugin</artifactId>
	<configuration>
		<appendAssemblyId>false</appendAssemblyId>
		<descriptorRefs>
			<descriptorRef>jar-with-dependencies</descriptorRef>
		</descriptorRefs>
		<archive>
			<manifest>
				<!-- 此处指定main方法入口的class -->
				<mainClass>WikipediaAnalysis</mainClass>
			</manifest>
		</archive>
	</configuration>
	<executions>
		<execution>
			<id>make-assembly</id>
			<phase>package</phase>
			<goals>
				<goal>assembly</goal>
			</goals>
		</execution>
	</executions>
</plugin>

二、maven打包指定本地jar包

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-jar-plugin</artifactId>
	<configuration>
		<archive>
			<manifest>
				<addClasspath>true</addClasspath>
				<classpathPrefix>lib/</classpathPrefix>
				<mainClass>WikipediaAnalysis</mainClass>
			</manifest>
		</archive>
	</configuration>
</plugin>
<!-- 拷贝依赖的jar包到lib目录 -->
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-dependency-plugin</artifactId>
	<executions>
		<execution>
			<id>copy</id>
			<phase>package</phase>
			<goals>
				<goal>copy-dependencies</goal>
			</goals>
			<configuration>
				<outputDirectory>
					${project.build.directory}/lib
				</outputDirectory>
			</configuration>
		</execution>
	</executions>
</plugin>

 

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页