Nous avons souvent ce type de scénario, nous avons juste besoin de faire de Spring Boot en un package de pot ordinaire, sans fichiers de configuration, pour que d'autres programmes s'appliquent
Cet article décrit comment utiliser Maven pour faire des applications de démarrage Spring dans des packages JAR non exécutables ordinaires.
Configurer Maven-Jar-Plugin
<Duild> <Glugins> <Glugin> <GroupId> org.springframework.boot </prôdId> <Artifactid> Spring-Boot-Maven-Plugin </ ArfactId> <FIGIGURATION> <CASSIFIER> EXEC </CASSIFIER> </ Configuration> </ Plugin> <pluffactive> <Artifactid> Maven-Jar-Plugin <artifactive> <Exécution> Maven-Jar-Jar-Plugin </ Artifactid> <Executid> Maven-Jar-Plugin <ARTIFACTID> <Artifactid> MAVEN-JAR-JAR-PLUGIN <id> exec </id> <masé> package </sathe> <objectifs> <butard> jar </ but> </ buts> <filony> <massifier> exec </smarsifier> </figuration> </ EXECUTION> </ EXECUTION> <masé> package </mathe> <buts> <objectif> <ForceCreation> true </ forceCreation> <cluses> <cords> application.yml </cutclude> </cluses> </FIGIGURATION> </EXECUTUTION> </EMECTRITIONS> </ Plugin> </Glugins> </Duild>
Exécuter le package MVN Clean
LocalHost: printemps-boot-tutorial-non-exécutable majunwei $ mvn package clean [info] scanning for projects ... [avertissement] [avertissement] Certains problèmes ont été rencontrés lors de la construction du modèle efficace pour com.majunwei: printemps-boot-tutorial-non-exécute org.apache.maven.plugins: Maven-Jar-Plugin est manquant. @ com.majunwei: printemps-boot-tutorial-Non-execuable: [Unknown-version], /users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-execuable/pom.xml, ligne 26, colonne 17 [en direction] 'build.plugins. org.springframework.boot: Spring-boot-maven-Plugin est manquant. @ com.majunwei: printemps-boot-tutorial-on-execuable: [inconnu-version], /users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/pom.xml, ligne 19, colonne 17 [assignation] [allége build. [avertissement] [avertissement] [info] [info] ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- / Utilisateurs / majunwei / documents / work / spring-boot-tutorial / printemp-boot-tutorial-non-excutable / cible [info] [info] --- maven-resources-Plugin: 2.6: ressources (resources par défaut) @ spring-boot-tutorial-non-excutable --- [info] utf-8 'Encoding to copyer les ressources filtées. --- Maven-Compiler-Plugin: 3.1: Compile (par défaut-Compile) @ Spring-Boot-tutorial-non-Exécutable --- [Info] Modifications détectées - Recompilation du module! [Info] Compilant 1 fichier source à / utilisateurs / Majunwei / Documents / Work / Spring-Boot-tutorial / Info-1-Boot-tutorial-non-oxecutable / Target / Classes / Classes / Classes / Classic Maven-Resources-Plugin: 2.6: TestResources (Default-TestResources) @ Spring-Boot-tutorial-non-Exécutable --- [Info] Utilisation du codage 'UTF-8' / Utilisateurs / majunwei / documents / work / spring-boot-tutorial / printemp-boot-tutorial-non-excutable / src / test / ressources [info] [info] --- maven-compiller-plagin: 3.1: testcompile (info de la valeur-test) @ toute-toot-tutorial-non-] - Infoable --- [Info] Maven-Surefire-Plugin: 2.12.4: Test (Test par défaut) @ Spring-Boot-tutorial-non-Exécutable --- [Info] Pas de tests à exécuter. [Info] [Info] --- Maven-Jar-Plugin: 2.4: JAR (Infauft-Jar) @ printemps-boot-tutorial-non-excutable --- [Info) Building Jar: /Users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-on-execuable/target/spring-boot-tutorial-non-execuable-0.0.1-snapshot.jarorth Spring-boot-tutorial-non-exécutable --- [info] construction jar: /users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-on-execuable/target/spring-boot-tutorial-on-execuable-0.0.1-snapshot-exec.jar[info] [info] Maven-Jar-Plugin: 2.4: Jar (par défaut) @ Spring-Boot-tutorial-non-Exécutable --- [info] Building Jar: /Users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-execuable/target/spring-boot-tutorial-non-execuable-0.0.1-snapshot.jar[info] --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 2017-08-07T18: 22: 50 + 08: 00 [info] Mémoire finale: 17m / 174m [info] -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Téléchargez le code source d'instance
Ce qui précède est tout le contenu de cet article. J'espère que cela sera utile à l'apprentissage de tous et j'espère que tout le monde soutiendra davantage Wulin.com.