Wir haben oft diese Art von Szenario. Wir müssen Spring -Boot nur in ein gewöhnliches JAR -Paket ohne Konfigurationsdateien machen, damit andere Programme sich bewerben können
In diesem Artikel wird beschrieben, wie Maven verwendet werden, um Spring-Boot-Anwendungen in gewöhnliche, nicht auszugehörige JAR-Pakete herzustellen.
Konfigurieren Sie Maven-Jar-Plugin
<build> <plugins> <plugin> <GroupId> org.springFramework <ID> exec </id> <phase> Paket </phase> <giele> <giele> jar </gara> </gores> <configuration> <classifier> exec </klassifizier> </configuration> </Ausführung> <Ausführung> <Phase> Paket </phase> <grosss> <giels <forcecreation> true </forcecreation> <ausschließt> <xclude> application.yml </exklued> </ausschließt> </configuration> </execution> </executions> </plugin> </plugins> </build>
Führen Sie MVN Clean Package aus
LOCALHOST: Spring-Boot-Tutorial-Non-Elei-majunwei $ mvn sauberes Paket [Info] Scannen nach Projekten ... [WARNUNG] [WARNUNG] Einige Probleme wurden beim Aufbau des effektiven Modells für Com.majunwei: Spring-Boot-Tutorial-Non-Execible: Jar: 0.0.1-Snapshot [Warning] 'building. org.apache.maven.plugins: maven-jar-plugin fehlt. @ com.majunwei: Spring-Boot-tutorial-non-eexecutable: [unbekannt-version], /users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-execable/pom.xml, Line 26, Spalte 17 [WARNING] 'Build.plugin.Plugin.version' für org.springframework.boot: Spring-Boot-Maven-Plugin fehlt. @ com.majunwei: Spring-Boot-tutorial-non-eexecutable: [unbekannt-version], /Users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-execable/pom.xml, Zeile 19, Drohung. Build. [Warnung] [Warnung] [Info] [Info] -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /Benutzer/Majunwei/Dokumente/Work/Spring-Boot-Tutorial/Spring-Boot-Tutorial-Non-Executable/Ziel [Info] [Info] --- Maven-Ressourcen-Plugin: 2.6: Ressourcen (Standard-Ressourcen) @ Spring-Boot-Tutorials-nicht-execriable --- [info] uTf-8 '-Dinkodierung. [Info] --- Maven-Compiler-Plugin: 3.1: kompilieren (Standard-Kompilen) @ Spring-Boot-Tutorial-nicht-executable --- [Info] Erkannt-neu kompiliert-Umkompilieren des Moduls! [Info] kompilieren 1 Quelldatei zu/user/majunwei/documents/klassifisch/klassifisch/foot-tutor/footor/footor/footor/footor/footor/footor/footor/footor/footor/footor- Maven-Ressources-Plugin: 2.6: TestResources (Standard-Testresources) @ Spring-Boot-Tutorial-nicht-Ausbau-[Info] Verwenden von 'UTF-8' -Codierung, um gefilterte Ressourcen zu kopieren. /Benutzer/Majunwei/Dokumente/Work/Spring-Boot-Tutorial/Spring-Boot-Tutorial-Non-Executable/SRC/Test/Ressourcen [Info] [Info] --- maven-compiler-plugin: 3.1: testcompile (Default-testcompile) @ Spring-boot-tutororororororororial-. Maven-Surefire-Plugin: 2.12.4: Test (Standard-Test) @ Spring-Boot-Tutorial-nicht-execurable --- [Info] Keine Tests zu führen. /Users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/spring-boot-tutorial-non-executury-0.0.1-snapshot.jar -info] [info] --- maven-jar-plugin: 2.4: jar (laca) @ @ ua Spring-Boot-Tutorial-Non-eexecutable --- [Info] Erstellen von Jar: /users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-eexecutable/target/spring-boot-tutorial-non-execledel-0.0.1-snapshot-exec.jar- Maven-Jar-Plugin: 2.4: Jar (Standard) @ Spring-Boot-Tutorial-nicht-ausschließlich --- [Info] Erstellen von Glas: /Users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/spring-boot-tutorial-non-executable-0.0.1-snapshot.jar- ------------------------------------------------------------------------------------------------------------------------------------------------------------- 2017-08-07T18:22:50+08:00[INFO] Final Memory: 17M/174M[INFO] ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Laden Sie den Instanzquellencode herunter
Das obige ist der gesamte Inhalt dieses Artikels. Ich hoffe, es wird für das Lernen aller hilfreich sein und ich hoffe, jeder wird Wulin.com mehr unterstützen.