คำนำ
Springboot ใช้แพ็คเกจ JAR เพื่อแยกไฟล์ LIB และการกำหนดค่า ฉันไม่ได้ลอง หลังจากพูดคุยกับ Liu Dashen (The Great God ไม่มีบล็อกมันน่าเสียดาย) ฉันได้ให้วิธีนี้สำหรับการอ้างอิงของคุณ
สภาพแวดล้อมการปรับใช้
pom.xml
<? xml version = "1.0" การเข้ารหัส = "utf-8"?> <project xmlns = "http://maven.apache.org/pom/4.0.0" xmlns: xsi = "http://www.w3.org/2001/ XSI: schemalocation = "http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" <Sersion> 0.0.1-SNAPSHOT </เวอร์ชัน> <packaging> jar </packaging> <name> ทดสอบ </name> <sention> ทดสอบ </คำอธิบาย> <carent> <menter> <roupId> org.springframework.boot </groupid> <ratifactid> <Project.build.sourceencoding> UTF-8 </project.build.sourceencoding> <project.raporting.OutputUntencoding> UTF-8 </project.Reporting.outputencoding> <RoupID> org.springframework.boot </groupId> <ratifactid> Spring-Boot-Starter-Web </artifactid> </serpendency> <perdency> <sderctive> <plugins> <plugin> <loupid> org.apache.maven.plugins </groupid> <ratifactId> maven- พึ่งพา-plugin </artifactid> <cenections> <cencution> <id> การตั้งค่าการคัดลอก </id> <pare> <EutputDirectory> Target/lib </utputDirectory> <EpcludeRansitive> FALSE </excludetransitive> <Stripversion> FALSE </Stripversion> <รวมถึงการรันไทม์ </includescope> <ArtIfactId> maven-jar-plugin </artifactid> <การกำหนดค่า> <excludes> <excrude> **/*. คุณสมบัติ </exclude> <exclude> **/*. xml </excrude> </การกำหนดค่า> </plugin> <plugin> <sloupid> org.springframework.boot </groupid> <ratifactid> Spring-Boot-Maven-Plugin </artifactid> <การกำหนดค่า> <dayout> zip </layout> <EXCUTIONS> <EXECUTION> <goals> <soal> การส่งซ้ำ </goal> </goals> <การกำหนดค่า> <classifier> คลาส </classifier> <mated> false </attact> </configuration> </execution> </encutions> </plugin> <ArtIfactId> maven-antrun-plugin </artifactiD> <cenections> <cencution> <pareguated> แพคเกจ </เฟส> <เป้าหมาย> <goal> เรียกใช้ </เป้าหมาย> </เป้าหมาย> <การกำหนดค่า> <garort> <property name = "dist"> เป้าหมาย/คุณสมบัติ> name = "app-name"> $ {project.artifactid}-$ {project.version} </คุณสมบัติ> <mkdir dir = "$ {dist-tmp}"/> <copy file = "เป้าหมาย/$ {app-name} .jar" tofile = "$ {dist-tmp}/$} src = "$ {dist-tmp}/$ {app-name} .jar" dest = "$ {dist-tmp}"/> <delete file = "$ {dist-tmp}/$ {app-name} .jar"/> dir = "$ {dist-tmp}/meta-inf" prefix = "meta-inf"/> <zipfileset dir = "target/classes/static" prefix = "คงที่"/> <zipfileset dir = "target/classes/templates" prefix = "templates"/> todir = "$ {dist}"/> <ย้าย todir = "$ {dist}/3rd-lib"> <fileset dir = "target/lib"/> </move> <delete dir = "$ {dist-tmp}"/> <copy todir = "$ {dist}" name = "**/*. xml"/> <include name = "**/*. yml"/> </fileset> </copy> </source> </การกำหนดค่า> </execution> </encutions> </plugin>หลังจากแพ็คเกจเสร็จสิ้น
ใช้โถ
java -jar -dloader.path =., 3rd-lib test-0.0.1-snapshot-classes.jar
สรุป
ด้านบนเป็นวิธีการกำหนดค่าที่ถูกต้องสำหรับการแยก LIB ออกจากแพ็คเกจขวดสปริงบูตที่ตัวแก้ไขแนะนำให้คุณ ฉันหวังว่ามันจะเป็นประโยชน์กับคุณ หากคุณมีคำถามใด ๆ โปรดฝากข้อความถึงฉันและบรรณาธิการจะตอบกลับคุณทันเวลา ขอบคุณมากสำหรับการสนับสนุนเว็บไซต์ Wulin.com!