详解Spring Boot使用Maven自定义打包方式

网友投稿 875 2023-02-26

详解Spring Boot使用Maven自定义打包方式

详解Spring Boot使用Maven自定义打包方式

前言:本文将告诉你如何将程序Jar与与依赖Jar及配置文件分离打包,以下列举了两种不同Maven打包方式,其打包效果一致!

一、第一种Maven打包方式,将jar及resources下全部配置文件,拷贝到指定目录:

E:/IDEAFile/file-copy/target/project

org.springframework.boot

spring-boot-maven-plugin

org.apache.maven.plugins

maven-jar-plugin

2.6

true

lib/

com.example.filecopy.Filhttp://eCopyApplication

maven-resources-plugin

copy-resources

validate

copy-resources

${project.build.directory}/project

src/main/resources

true

</executions>

maven-antrun-plugin

package

run

第二种Maven打包方式使用 assembly插件,将jar及配置文件进行压缩打包到指定目录:

org.springframework.boot

spring-boot-maven-plugin

org.apache.maven.plugins

maven-jar-plugin

2.6

true

lib/

com.example.filecopy.FileCopyApplication

org.apache.maven.plugins

maven-assembly-plugin

2.4

project

/assembly/assembly.xml

${project.build.directory}

false

package

single

assembly文件:

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">

leaves

zip

true

${basedir}/src/main/resources

**

true

${file.separator}

${project.build.directory}

${file.separator}

*.jar

xmlns:xsi="http://w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">

leaves

zip

true

${basedir}/src/main/resources

**

true

${file.separator}

${project.build.directory}

${file.separator}

*.jar

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:怎么制作小程序插件手机版(怎么制作小程序插件手机版)
下一篇:springboot2整合redis使用lettuce连接池的方法(解决lettuce连接池无效问题)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~