머리말
SpringBoot는 JAR 패키지를 사용하여 LIB와 구성 파일을 분리합니다. 나는 그것을 시도하지 않았다. Liu Dashen (The Great God는 블로그가없고 동정입니다)과 논의한 후, 나는 당신의 참조를 위해이 해결책을 주었다.
배포 환경
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.xsd"> <modeversion> 4.0.0 </modelversion> <groupid> com.elvish </groupid> <Artifactid> test> <버전> 0.0.1-snapshot </version> <packaging> jar </packaging> <name> test </name> <description> test </descript> <부모> <groupid> org.springframework.boot </groupId> <artifactid> spring-boot-starter-parent </artifactid> <version> 1.5.10. </////peratiets> release. <project.build.sourceencoding> utf-8 </project.build.sourceencoding> <project.reporting.outputencoding> utf-8 </project.reporting.outputencoding> <java.version> 1.8 </java.version> </properties> <pelovemencies> <groupid> org.springframework.boot </groupid> <artifactid> Spring-Boot-Starter-web </arevicAtid> </fectionency> <pectionement> <groupId> org.springframewort </groupid> <artifactid> spring-boot-starter-themelef </eppliteMENT> <Plugin> <groupId> org.apache.maven.plugins </groupid> <artifactid> maven- 의존적 -plugin </artifactid> <executions> <executions> <id> 카피-의존성 </id> <case> 패키지 </phase> <Goals> <goving> copy-dependents </boving> <구성> < <outputDirectory> target/lib </outputDirectory> <excludeTransitive> false </excludeTransitive> <tripversion> false </stripversion> <IncludEscope> runtime </includEscope> </configuration> </executions> </plugin> <flugin> <groupid> org.apache.maven.plugins. <artifactid> maven-jar-plugin </artifactid> <configuration> <configuration> <excludes> <exclude> **/*. 속성 </exclude> <exclude> **/*. xml </exclude> <exclude> **/* </excludes> </configuration> </plugin> <plugin> <groupid> org.springframework.boot </groupid> <artifactid> spring-boot-maven-plugin </artifactid> <layout> zip </layout> <clender> <conlerat> nonexists> <artifact> nonifactid> nonifactid> </include> </configuration> <executions> <executions> <Goals> <Goal> Repackage </goal> </gover> <configuration> <clatifier> 클래스 </classifier> <atchifier> <atchif> false </att <Artifactid> maven-antrun-plugin </artifactid> <executions> <executions> <pase> package </phase> <pase> goal> run </boging> </govent> <garget> <target> <property name = "dist"> target/property name = "target-tmp "> target/distribution * 이름 = "app-name"> $ {project.artifactid}-$ {project.version} </propert> <mkdir dir = "$ {dist-tmp}"/> <copy file = "target/$ {app-name} .jar"tofile = "$ {dist-tmp}/$ {app-name} src = "$ {dist-tmp}/$ {app-name} .jar"dest = "$ {dist-tmp}"/> <delete file = "$ {dist-tmp}/$ {app-name} .jar"/> <zip destfile = "$ {app-name} --pages.jar" dir = "$ {dist-tmp}/meta-inf"prefix = "meta-inf"/> <zipfileset dir = "target/classe/static"prefix = "static"/> <zipfileset dir = "target/classes/emplates"prefix = "templates"/> </zip> <target/$ {app-name} -jar "-class.jar" todir = "$ {dist}"/> <move todir = "$ {dist}/3rd-lib"> <fileset dir = "target/lib"/> </mak> <delete dir = "$ {dist-tmp}"/> <copy todir = "$ {dir}"> <target/classes "> <invogy name ="/*. 이름 = "**/*. xml"/> <포함 이름 = "**/*. yml"/> </fileset> </copy> </target> </configuration> </execution> </executions> </plugin> </plugins> </project> </project>패키지가 완료된 후
항아리를 실행하십시오
java -jar -dloader.path =., 3rd-lib test-0.0.1-snapshot classes.jar
요약
위는 편집자가 소개 한 Spring Boot Jar 패키지에서 lib를 분리하기위한 올바른 구성 방법입니다. 나는 그것이 당신에게 도움이되기를 바랍니다. 궁금한 점이 있으면 메시지를 남겨 주시면 편집자가 제 시간에 답장을 드리겠습니다. Wulin.com 웹 사이트를 지원해 주셔서 대단히 감사합니다!