第一個Spring Boot程序啟動報錯了


創建完成第一個Spring Boot項目后,准備運行,嘗一下勝利的果實。
啟動日志如下
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.1.RELEASE)

2019-01-09 21:10:41.812  INFO 11644 --- [           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: default
2019-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
沒有報錯,但是,這是一個web項目,為什么自己就結束了呢?
查閱資料(百度)
發現 pom文件有問題,這里不啰嗦,直接上代碼
<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>    
pom文件中有這個依賴,這個是什么意思呢?
簡單來說就是:我把外部的一個tomcat引入了。
這下你明白了吧,spring boot內部本來就有一個。你現在又引入了一個,這下出問題了。
解決方案:
把上述代碼做掉(刪除)。問題解決
重新啟動項目:
日志如下
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: 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)

 未完待續。。。。。。。。。

下面繼續....

番外篇


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM