Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

最近開始使用idea,上來就這麼一個錯誤。搜索總結如下:

我的依賴是這樣的:


provided 依賴只有在當JDK 或者一個容器已提供該依賴之後才使用。例如, 如果你開發了一個web 應用,你可能在編譯

classpath 中需要可用的Servlet API 來編譯一個servlet,但是你不會想要在打包好的WAR 中包含這個Servlet API;這個

Servlet API JAR 由你的應用服務器或者servlet 容器提供。已提供範圍的依賴在編譯classpath (不是運行時)可用。它們

不是傳遞性的,也不會被打包。


在 Intellij Idea 15 中使用maven時,所有 scope 爲 provided 的依賴都是不會被加入到 classpath 中的,目前該bug尚未被修復(bug report)。如果你的web應用是部署到容器中的,那麼這個bug不會影響使用,因爲web應用中provided的依賴在容器運行時會被提供。如果你做Spring Boot開發,有帶provided的依賴時,直接在IDE中運行項目會導致ClassNotFound異常。解決方案有二:

  • 使用spring-boot:run這個 maven goal 運行程序。但這樣會失去 Idea 的 debug功能,不推薦。
  • 點擊IDE右側的Maven Projects, 找到spring-boot:run,右鍵選擇 debug 運行,如圖:

  • 參考文檔地址:http://blog.csdn.net/neosmith/article/details/50924681###; 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章