第一個Spring Boot程式啟動報錯了
阿新 • • 發佈:2019-01-09
建立完成第一個Spring Boot專案後,準備執行,嘗一下勝利的果實。
啟動日誌如下
pom檔案中有這個依賴,這個是什麼意思呢?
簡單來說就是:我把外部的一個tomcat引入了。
這下你明白了吧,spring boot內部本來就有一個。你現在又引入了一個,這下出問題了。
解決方案:
把上述程式碼做掉(刪除)。問題解決
重新啟動專案:
日誌如下
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.1.RELEASE) 2019-01-09 21:10:41.812 INFO 11644沒有報錯,但是,這是一個web專案,為什麼自己就結束了呢? 查閱資料(百度) 發現 pom檔案有問題,這裡不囉嗦,直接上程式碼--- [ main] com.example.demo01.Demo01Application : Starting Demo01Application on 20180528-132245 with PID 11644 (D:\SpringBoot\project\demo01\target\classes started by Administrator in D:\SpringBoot\project\demo01) 2019-01-09 21:10:41.821 INFO 11644 --- [ main] com.example.demo01.Demo01Application : No active profile set, falling back to default profiles: default2019-01-09 21:10:43.160 INFO 11644 --- [ main] com.example.demo01.Demo01Application : Started Demo01Application in 1.955 seconds (JVM running for 3.395) Process finished with exit code 0
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.1.RELEASE) 2019-01-09 21:12:18.385 INFO 6780 --- [ main] com.example.demo01.Demo01Application : Starting Demo01Application on 20180528-132245 with PID 6780 (D:\SpringBoot\project\demo01\target\classes started by Administrator in D:\SpringBoot\project\demo01) 2019-01-09 21:12:18.391 INFO 6780 --- [ main] com.example.demo01.Demo01Application : No active profile set, falling back to default profiles: default 2019-01-09 21:12:19.851 INFO 6780 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2019-01-09 21:12:19.875 INFO 6780 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-01-09 21:12:19.875 INFO 6780 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/9.0.13 2019-01-09 21:12:19.882 INFO 6780 --- [ main] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [D:\Program Files\Java\jdk1.8.0_172\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;D:\Python37;D:\Program Files (x86)\Sybase\PowerDesigner 16;D:\oracle\product\10.2.0\db_1\bin;D:\app\Administrator\product\11.2.0\client_1;D:\maven\apache-maven-3.5.0\bin;D:\Program Files\Java\jdk1.7.0_80\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;D:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;D:\Program Files\EmEditor;D:\Python37\Scripts;D:\Python37\Lib\site-packages\Django-2.1.2-py3.7.egg\django;D:\Program Files\Git\cmd;D:\Python37\Scripts\;D:\Python37\;.] 2019-01-09 21:12:20.011 INFO 6780 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-01-09 21:12:20.011 INFO 6780 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1530 ms 2019-01-09 21:12:20.236 INFO 6780 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2019-01-09 21:12:20.463 INFO 6780 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2019-01-09 21:12:20.469 INFO 6780 --- [ main] com.example.demo01.Demo01Application : Started Demo01Application in 2.713 seconds (JVM running for 3.954)