spring boot 打包,不将依赖第三方jar打包

问题:

今天项目上有个问题,使用spring boot开发的系统,在利用spring boot的打包插件打包后,生成的jar太大,对于远程更新不方便。

可能是我对spring boot插件不熟悉,暂不考虑。

解决:

利用maven-jar-plugin插件进行打包。配置如下:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
	<configuration>
		<archive>
			<manifest>
				<mainClass>com.ds.xx.xx.Application</mainClass> <!--//指定Springboot程序启动类-->
				<addClasspath>true</addClasspath>
				<classpathPrefix>lib/</classpathPrefix> <!--//指定依赖的jar包相对于本程序jar的位置-->
			</manifest>
			<manifestEntries>
				<Class-Path>./</Class-Path>
			</manifestEntries>
		</archive>
		<excludes>
			<exclude>mapping/**</exclude>
			<exclude>templates/**</exclude>
			<!-- //指定打包时要排除的文件,支持正则-->
			<!--<exclude>config/**</exclude>
			<exclude>logback-spring.xml</exclude> -->
			<exclude>application.yml</exclude>
		</excludes>
	</configuration>
</plugin>

说明:

<archive>标签中<manifestFile>来配置MANIFEST.MF的自定义参数,这里指定了主程序执行类,同时指定主程序执行时依赖的第三方jar包从当前目录的lib/查找。

<excludes>配置,不需要打包到的jar包的资源文件。

猜你喜欢

转载自blog.csdn.net/zerozone100523/article/details/85321911