我正在尝试启动Spring启动应用程序。获得以下例外:
Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jettyEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedJetty.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory]: Factory method 'jettyEmbeddedServletContainerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/webapp/WebAppContext
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at com.filinv.rtl.ei.ao.app.Application.main(Application.java:10)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jettyEmbeddedServletContainerFactory' defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedJetty.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory]: Factory method 'jettyEmbeddedServletContainerFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/webapp/WebAppContext
mvn依赖:树
*+- org.apache.cxf:cxf-rt-transports-http:jar:3.0.0-milestone1:compile
[INFO] | \- org.apache.cxf:cxf-rt-transports-http-jetty:jar:3.0.0-milestone1:compile
[INFO] | +- org.eclipse.jetty:jetty-server:jar:9.2.11.v20150529:compile
[INFO] | | +- org.eclipse.jetty:jetty-http:jar:9.2.11.v20150529:compile
[INFO] | | | \- org.eclipse.jetty:jetty-util:jar:9.2.11.v20150529:compile
[INFO] | | \- org.eclipse.jetty:jetty-io:jar:9.2.11.v20150529:compile
[INFO] | +- org.eclipse.jetty:jetty-security:jar:9.2.11.v20150529:compile*
答案 0 :(得分:3)
你在Spring Boot中遇到a bug,它试图自动配置Jetty,即使它的必需部分不在类路径上。该错误已在Spring Boot 1.2.7.RELEASE中修复。您还没有说过您正在使用的版本,但我认为它早于此版本。升级到最新版本应该可以解决您的问题。在撰写本文时,最新版本为1.3.3.RELEASE。