關于idea,springboot啟動最新版ibase4j報Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
使用ibase4j開發了一段時間,兩個字“好用”。不過最近有新入行的朋友需要分享一下ibase4j。
于是就去下載了最新版本的ibase4j,給新朋友演示。后面就出問題了,項目啟動就報:
Error starting ApplicationContext.
To display the conditions
report re-run your application
with 'debug' enabled.
2018-
09-
03 17:
07:
53.540 [main] ERROR [SpringApplication:
842] - Application run failed
org.springframework.
context.ApplicationContextException: Unable
to start web server; nested exception
is org.springframework.
context.ApplicationContextException: Unable
to start ServletWebServerApplicationContext due
to missing ServletWebServerFactory bean.at org.springframework.boot.web.servlet.
context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:
155) ~[spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.springframework.
context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:
544) ~[spring-
context-
5.0.7.
RELEASE.jar:
5.0.7.
RELEASE]at org.springframework.boot.web.servlet.
context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:
140) ~[spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:
759) [spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:
395) [spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:
327) [spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:
1255) [spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:
1243) [spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.ibase4j.SysServiceApplication.main(SysServiceApplication.java:
13) [classes/:?]
Caused by: org.springframework.
context.ApplicationContextException: Unable
to start ServletWebServerApplicationContext due
to missing ServletWebServerFactory bean.at org.springframework.boot.web.servlet.
context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:
204) ~[spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.springframework.boot.web.servlet.
context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:
178) ~[spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]at org.springframework.boot.web.servlet.
context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:
152) ~[spring-boot-
2.0.3.
RELEASE.jar:
2.0.3.
RELEASE]...
8 more
這個錯誤,后面使用百度csdn博文+翻看源碼+ibase4j Q群詢問后發現是如下代碼導致:
在ibase4j的主maven配置文件pom.xm里有關springboot的依賴tomcat有如下配置
<dependency><groupId>org.springframework.boot
</groupId><artifactId>spring-boot-starter-tomcat
</artifactId><scope>provided
</scope></dependency>
scope:provided表示產于編譯運行,但不參與打包,打包由生產環境提供。
于是把scope的provided改成了complie,果然啟動成功。
但是,作者既然這樣配置,那么表示應該是可以運行的。考慮到作者可能是用eclipse開發。
于是查看了idea的啟動配置,果然發現了問題。
選擇Edit Configuration…
選擇SpringBoot的配置,勾上Include dependencies with “Provided” scope
點擊OK
再次啟動項目,運行成功!
總結這個應該是開發環境差異導致。明顯idea提供這個勾選項,是為了方便用戶打包,但是在運行時,需要勾上。
參考:
1、iBase4J一群 聊天記錄
2、maven中scope標簽詳解
總結
以上是生活随笔為你收集整理的关于idea,springboot启动最新版ibase4j报Unable to start ServletWebServerApplicationContext due to missing Serv的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。