Maison  >  Article  >  Java  >  Comment utiliser bat pour démarrer le projet Springboot

Comment utiliser bat pour démarrer le projet Springboot

WBOY
WBOYavant
2023-05-14 13:34:062021parcourir

1.springboot project packaging jar

Comment utiliser bat pour démarrer le projet Springboot

Après l'emballage, placez-le dans le répertoire suivant :

#🎜 🎜## 🎜🎜#Comment utiliser bat pour démarrer le projet SpringbootLe fichier jar Springboot fourni ici s'appelle api-0.0.1-SNAPSHOT.jar

2 Écrivez un script Springboot de démarrage de chauve-souris

#🎜🎜. #Créez un nouveau fichier start.bat, le contenu du fichier start.bat est le suivant :

cd %~dp0

C:jdkjdk1.8.0_181binjava.exe -Dfile.encoding=utf-8 - jar api-0.0.1-SNAPSHOT.jar --server.port=81


cd %~dp0 signifie passer au répertoire où se trouve bat localisé

- Dfile.encoding=utf-8 Définissez l'encodage

--server.port=81 Définissez le port d'accès Springboot sur 81

3. bat start springboot

#🎜🎜 #Supposons que les fichiers api-0.0.1-SNAPSHOT.jar et start.bat soient placés dans le répertoire d:apidemo

Double-cliquez sur le démarrage. bat et une console apparaîtra automatiquement. Les informations sont les suivantes : # 🎜🎜#

D:apidemo>cd D:apidemo

D : apidemo>C:jdkjdk1.8.0_181binjava.exe -Dfile.encoding=utf- 8 -jar api-0.0.
1-SNAPSHOT.jar --server.port=81


____ . _ _ _ _ _

/\ / ___'_ __ _ _ (_)_ __ __ _

( ( )___ | '_ | '_| | '_ / _` | #🎜🎜 # \/ ___)| |_) || (_ | | ) ) )
|____| |_|_| 🎜🎜# ========|_|== ============|___/=/_/_/_/

:: Spring Boot :: ( v2.4.3)


2021-06- 19 16:28:33.392 INFO 4436 --- [ main] com.demo.api.ApiApp
lication : Démarrage d'ApiApplication v0.0.1-SNAPSHOT utilisant Java 1.8.0_181
sur iZ23lkh hnpiZ avec PID 4436 (D :apidemoapi-0.0.1-SNAPSHOT.jar démarré par Ad
administrateur dans D:apidemo)
2021-06-19 16 :28:33.392 INFO 4436 --- [      main] com.demo.api .ApiApp
lication : Aucun profil actif défini, retour aux profils par défaut : def

ault

2021-06- 19 16:28:37.236 INFO 4436 --- [ principal] o.s.b.w.embedded.tomcat
.TomcatWebServer : Tomcat initialisé avec le(s) port(s) : 81 (http)
2021-06-19 16:28 : 37.298 INFO 4436 --- [ principal] o.apache.catalina.core
StandardService : Démarrage du service [Tomcat]
2021-06-19 16:28:37.298 INFO 4436 --- [ principal] org.apache.catalina.cor
e.StandardEngine : Démarrage du moteur de servlet : [Apache Tomcat/9.0.43]
2021-06-19 16:28:37.454 INFO 4436 --- [ principal] o.a.c.c.C. [Tomcat].[loc
alhost].[/] : Initialisation du WebApplicationContext intégré à Spring
2021-06-19 16:28:37.470 INFO 4436 --- [ main] w.s.c.ServletWebServerA
pplicationContext : Root WebApplicationContext : initialisation terminée 3891
ms
2021-06-19 16:28:38.064 INFO 4436 --- [ main] o.s.s.concurrent.Thread
PoolTaskExecutor : Initialisation d'ExecutorService 'applicationTaskExecutor'
2021-06-19 16 : 28:38.626 INFO 4436 - -- [ main] o.s.b.w.embedded.tomcat
.TomcatWebServer : Tomcat démarré sur le(s) port(s) : 81 (http) avec le chemin contextuel ''
2021-06-19 16:28:38.642 INFO 4436 - -- [ main] com.demo.api.ApiApp
lication : ApiApplication démarrée en 6,504 secondes (JVM fonctionnant sous 7.7
85 )


4. Questions fréquemment posées

4.1 Résolvez le problème des caractères chinois tronqués dans la console de chauve-souris

#🎜🎜. #[Phénomènes]

#🎜 🎜#

[Solution]

L'encodage de le fichier start.bat est défini sur UTF-8. Ce qui suit utilise Notepad++ comme exemple

#🎜🎜 #

Comment utiliser bat pour démarrer le projet Springboot

【Après l'effet de la solution】

Comment utiliser bat pour démarrer le projet Springboot

4.2.cd %~dp0 n'est pas une commande interne ou externe

[Phénomènes]

D:apidemo>锘缟d D:apidemo
'锘缟d' n'est pas une commande interne ou externe, ni est-ce un programme exploitable
ou un fichier batch.

【Solution】

Il y a d'autres correspondances dans start.bat Veuillez retaper la commande dans Notepad++ ou changer l'encodage.

【Résultat après solution】

D:apidemo>cd D:apidemo

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Cet article est reproduit dans:. en cas de violation, veuillez contacter admin@php.cn Supprimer