【sprinb-boot】配置和lib分离打包
生活随笔
收集整理的這篇文章主要介紹了
【sprinb-boot】配置和lib分离打包
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
前言
- springboot 2.0.0.RELEASE
- maven 3.5.0
使用maven命令mvn package打包spring boot項(xiàng)目時(shí),將配置和lib分離出來。
pom.xml配置
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><build>...<plugins><!-- 配置和lib分離打包步驟 : 1,jar -> 2,copy-dependencies -> 3,copy-resources -> 4,repackage --><!-- 配置和lib分離打包1/4 jar : 配置不打包到j(luò)ar中 --><plugin><artifactId>maven-jar-plugin</artifactId><configuration><excludes><exclude>application*.properties</exclude><exclude>messages*.properties</exclude><exclude>*.xml</exclude></excludes></configuration></plugin><!-- 配置和lib分離打包2/4 copy-dependencies : 拷貝依賴文件 --><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><executions><execution><id>copy-dependencies</id><phase>package</phase><goals><goal>copy-dependencies</goal></goals><configuration><outputDirectory>${project.build.directory}/final-package/lib/</outputDirectory></configuration></execution></executions></plugin><!-- 配置和lib分離打包3/4 copy-resources : 拷貝配置文件 --><plugin><artifactId>maven-resources-plugin</artifactId><configuration></configuration><executions><execution><id>copy-resources</id><phase>package</phase><goals><goal>copy-resources</goal></goals><configuration><resources><resource><directory>src/main/resources</directory><includes><include>application.properties</include><include>logback-spring.xml</include><include>messages*.properties</include></includes></resource></resources><outputDirectory>${project.build.directory}/final-package</outputDirectory></configuration></execution></executions></plugin><!-- 配置和lib分離打包4/4 repackage : spring boot 打包設(shè)置,不打包lib --><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><executions><execution><goals><goal>repackage</goal></goals><configuration><includes><!--不將依賴的jar打包到spring boot的jar/war中 --><include><groupId>null</groupId><artifactId>null</artifactId></include></includes><layout>ZIP</layout><!--設(shè)置spring boot的jar/war的存放路徑 --><outputDirectory>${project.build.directory}/final-package</outputDirectory></configuration></execution></executions></plugin></plugins></build>... </project>打包命令
mvn clean package啟動(dòng)命令
java -Dloader.path=lib -jar xxx-springboot-app.jar總結(jié)
以上是生活随笔為你收集整理的【sprinb-boot】配置和lib分离打包的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何快速治疗耳鸣
- 下一篇: 眼外伤玻璃体切割术后多久可以碰水