前言:本文将告诉你如何将程序Jar与与依赖Jar及配置文件分离打包,以下列举了两种不同Maven打包方式,其打包效果一致!
一、第一种Maven打包方式,将jar及resources下全部配置文件,拷贝到指定目录:
E:/IDEAFile/file-copy/target/project org.springframework.boot spring-boot-maven-pluginorg.apache.maven.plugins maven-jar-plugin2.6 true lib/ com.example.filecopy.FileCopyApplication maven-resources-plugin copy-resources validate copy-resources ${project.build.directory}/project src/main/resources true maven-antrun-plugin package run
第二种Maven打包方式使用 assembly插件,将jar及配置文件进行压缩打包到指定目录:
org.springframework.boot spring-boot-maven-pluginorg.apache.maven.plugins maven-jar-plugin2.6 true lib/ com.example.filecopy.FileCopyApplication org.apache.maven.plugins maven-assembly-plugin2.4 project /assembly/assembly.xml ${project.build.directory} falsepackage single
assembly文件:
leaves zip true ${basedir}/src/main/resources ** true ${file.separator} ${project.build.directory} ${file.separator} *.jar
到此这篇关于Spring Boot使用Maven自定义打包方式的文章就介绍到这了,更多相关Spring Boot Maven自定义打包内容请搜索考高分网以前的文章或继续浏览下面的相关文章希望大家以后多多支持考高分网!



