啓動spring boot 項目後拋出以下異常:java
1 org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat 2 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 3 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536) ~[spring-context-4.3.4.RELEASE.jar!/:4.3.4.RELEASE] 4 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 5 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 6 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 7 at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 8 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 9 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 10 at com.jiajian.JerseyTestDemoApplication.main(JerseyTestDemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT] 11 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91] 12 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_91] 13 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_91] 14 at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_91] 15 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [jersey-test-demo-0.0.1-SNAPSHOT.war:0.0.1-SNAPSHOT] 16 at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [jersey-test-demo-0.0.1-SNAPSHOT.war:0.0.1-SNAPSHOT] 17 at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [jersey-test-demo-0.0.1-SNAPSHOT.war:0.0.1-SNAPSHOT] 18 at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) [jersey-test-demo-0.0.1-SNAPSHOT.war:0.0.1-SNAPSHOT] 19 Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat 20 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:115) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 21 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:82) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 22 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:535) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 23 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:177) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 24 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 25 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 26 ... 16 common frames omitted 27 Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]] 28 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.6.jar!/:8.5.6] 29 at org.apache.catalina.startup.Tomcat.start(Tomcat.java:356) ~[tomcat-embed-core-8.5.6.jar!/:8.5.6] 30 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:96) ~[spring-boot-1.4.2.RELEASE.jar!/:1.4.2.RELEASE] 31 ... 21 common frames omitted 32 Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Tomcat]] 33 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.6.jar!/:8.5.6] 34 at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:791) ~[tomcat-embed-core-8.5.6.jar!/:8.5.6] 35 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.6.jar!/:8.5.6] 36 ... 23 common frames omitted
緣由是由於項目中引用了spring
<groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId>
tomcat7依賴中也有此包,形成屢次引用依賴致使的jar包衝突致使的報錯,只需將pom.xml中的幹掉就能夠了,再也不衝突了,就能夠快樂地寫 RESTful風格的API提供給客戶端or服務端調用了, so easy !apache