Spring boot 启动Spring启动应用程序时获取jetty服务器的NoClassDefFoundError
我正在尝试启动spring启动应用程序。获取以下异常:Spring boot 启动Spring启动应用程序时获取jetty服务器的NoClassDefFoundError,spring-boot,Spring Boot,我正在尝试启动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
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*
在SpringBoot中,它尝试自动配置Jetty,即使它的必需部分不在类路径上。该错误在Spring Boot 1.2.7.0版本中修复。你还没有说你使用的是什么版本,但我认为它早于此。升级到最新版本应该可以解决您的问题。在编写本文时,最新版本是1.3.3。发行版。通过将cxf rt传输http jetty JAR从类路径中排除,从而修复了导致版本不匹配的问题。我使用的是1.3.6,但仍然得到了这个问题。@DurgaSwaroop这可能最好在一个新问题中解决