一.项目结构 二.pom.xml所依赖插件使用maven-assembly-plugin,对Springboot打包进行分离,以下代码直接复制粘贴,在按照给出的项目结构创建下,只需要修改pom.xml中的项目名字、Application的路径,assembly.xml中的id、打包格式即可使用。
三.assembly.xml 文件sync src/main/resources *.properties *.xml *.yaml *.yml true org.apache.maven.plugins maven-compiler-plugin1.8 1.8 UTF-8 org.apache.maven.plugins maven-jar-plugin2.6 true lib com.demo.sync.SyncApplication ./ *.properties *.yml *.yaml *.xml config/** org.apache.maven.plugins maven-dependency-plugincopy-dep prepare-package copy-dependencies ${project.build.directory}/lib false false true org.apache.maven.plugins maven-assembly-plugin2.6 1.0 package single ${basedir}/src/main/assembly/assembly.xml
1.0
tar.gz
true
${basedir}/src/main/resources
*.yml
*.yaml
*.properties
*.xml
0644
/config
${basedir}/src/main/bin
*.sh
*.bat
0755
/bin
${project.build.directory}
/
*.jar
/lib/*
0755
四.打包后格式
1.项目target目录格式:
2.只需上传压缩包到服务器即可,压缩包目录格式:



