2016-02-23 54 views
0

我已經使用eclipse IDE創建了spring rest服務。當我運行但是使用調試配置,它可以在Eclipse中正常,當我出口它作爲一個可執行的JAR文件並運行使用下面的命令Spring引導jar無法啓動嵌入式tomcat

java -jar cs.jar 

它給了我下面的錯誤:

org.springframework.context.ApplicationContextException: Unable to start embedde 
d container; nested exception is org.springframework.boot.context.embedded.Embed 
dedServletContainerException: Unable to start embedded Tomcat 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte 
xt.onRefresh(EmbeddedWebApplicationContext.java:124) 
     at org.springframework.context.support.AbstractApplicationContext.refres 
h(AbstractApplicationContext.java:474) 
     at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte 
xt.refresh(EmbeddedWebApplicationContext.java:109) 

爲什麼它不工作作爲一個罐子?

+1

請所有的日誌輸出 –

回答

1

您需要檢查您的類路徑中是否包含了servlet-api jar,如果是,請將其刪除。

如果servlet-api在classpath中,它包含在WEB-INF/lib中,然後拋出錯誤,因爲servlet容器已經有servlet api jar。從行家或

刪除servlet的API的依賴gradle這個如果退出,或者如果這種依賴性是通過任何其他模塊添加然後排除像下面

<dependency> 
    <groupId><groupId></groupId> 
    <artifactId><some dependency></artifactId> 
    <version><version></version> 
    <exclusions> 
     <exclusion> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
     </exclusion> 
    </exclusions> 
</dependency> 
+0

此解決更新您的問題Servlet API的依賴我的問題 !謝謝 –

相關問題