我对Gradle
和SpringBoot
插件相对较新。
我正在尝试创建一个SpringBoot
WAR文件,其中Jetty
作为容器。
我正在使用带有2.0.2.RELEASE
的SpringBoot spring-boot-starter-jetty
,它带来了 Spring 5.0.6.RELEASE 和 Jetty 9.4.10.v20180503 (其中据我所知是兼容的)。
我的WAR文件中没有看到任何版本的不一致,但是在运行已组装的bootWar时,我得到以下异常:
[2018-05-11T18:28:09,432错误主要SpringApplication]应用程序运行失败 org.springframework.boot.web.server.WebServerException:无法启动嵌入式Jetty服务器 在org.springframework.boot.web.embedded.jetty.JettyWebServer.start(JettyWebServer.java:167)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:300)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)〜[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:327)[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在com.focusvq.fts.spring.Application.main(Application.java:17)[classes!/:1.0] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)〜[?:1.8.0_101] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[?:1.8.0_101] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜[?:1.8.0_101] 在java.lang.reflect.Method.invoke(Method.java:498)〜[?:1.8.0_101] 在org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)[fts-data-1.0.war:1.0] 在org.springframework.boot.loader.Launcher.launch(Launcher.java:87)[fts-data-1.0.war:1.0] 在org.springframework.boot.loader.Launcher.launch(Launcher.java:50)[fts-data-1.0.war:1.0] 在org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:58)[fts-data-1.0.war:1.0] 引起:javax.servlet.ServletException:dispatcherServlet @ 7ef5559e == org.springframework.web.servlet.DispatcherServlet,jsp = null,order = -1,inst = false 在org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:691)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] 在org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:427)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] 在org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] at org.springframework.boot.web.embedded.jetty.JettyEmbeddedWebAppContext $ JettyEmbeddedServletHandler.deferredInitialize(JettyEmbeddedWebAppContext.java:46)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] at org.springframework.boot.web.embedded.jetty.JettyEmbeddedWebAppContext.deferredInitialize(JettyEmbeddedWebAppContext.java:36)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.web.embedded.jetty.JettyWebServer.handleDeferredInitialize(JettyWebServer.java:209)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.web.embedded.jetty.JettyWebServer.start(JettyWebServer.java:141)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] ......还有18个 引起:org.springframework.beans.factory.BeanCreationException:创建名称为' org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping'的bean时出错:bean的初始化失败;嵌套异常是java.lang.NoSuchMethodError:org.springframework.web.servlet.handler.AbstractHandlerMapping.obtainApplicationContext()Lorg / springframework / context / ApplicationContext; 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:587)〜[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)〜[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:303)〜[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.createDefaultStrategy(DispatcherServlet.java:879)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.getDefaultStrategies(DispatcherServlet.java:847)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.initHandlerMappings(DispatcherServlet.java:606)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:501)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.onRefresh(DispatcherServlet.java:490)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:561)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在javax.servlet.GenericServlet.init(GenericServlet.java:244)〜[javax.servlet-api-3.1.0.jar!/:3.1.0] 在org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:670)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] 在org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:427)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] 在org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] at org.springframework.boot.web.embedded.jetty.JettyEmbeddedWebAppContext $ JettyEmbeddedServletHandler.deferredInitialize(JettyEmbeddedWebAppContext.java:46)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] at org.springframework.boot.web.embedded.jetty.JettyEmbeddedWebAppContext.deferredInitialize(JettyEmbeddedWebAppContext.java:36)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.web.embedded.jetty.JettyWebServer.handleDeferredInitialize(JettyWebServer.java:209)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.web.embedded.jetty.JettyWebServer.start(JettyWebServer.java:141)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] ......还有18个 引起:java.lang.NoSuchMethodError:org.springframework.web.servlet.handler.AbstractHandlerMapping.obtainApplicationContext()Lorg / springframework / context / ApplicationContext; 在org.springframework.web.servlet.handler.AbstractHandlerMapping.detectMappedInterceptors(AbstractHandlerMapping.java:269)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.handler.AbstractHandlerMapping.initApplicationContext(AbstractHandlerMapping.java:243)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping.initApplicationContext(AbstractDetectingUrlHandlerMapping.java:58)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.context.support.ApplicationObjectSupport.initApplicationContext(ApplicationObjectSupport.java:120)〜[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext(WebApplicationObjectSupport.java:77)〜[spring-web-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.context.support.ApplicationObjectSupport.setApplicationContext(ApplicationObjectSupport.java:74)〜[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:121)〜[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:97)〜[spring-context-4.3.12.RELEASE.jar!/:4.3.12.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422)〜[!弹簧豆-5.0.6.RELEASE.jar /:5.0.6.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1698)〜[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)〜[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)〜[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:303)〜[spring-beans-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.createDefaultStrategy(DispatcherServlet.java:879)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.getDefaultStrategies(DispatcherServlet.java:847)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.initHandlerMappings(DispatcherServlet.java:606)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:501)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.DispatcherServlet.onRefresh(DispatcherServlet.java:490)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:561)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:499)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:172)〜[spring-webmvc-5.0.6.RELEASE.jar!/:5.0.6.RELEASE] 在javax.servlet.GenericServlet.init(GenericServlet.java:244)〜[javax.servlet-api-3.1.0.jar!/:3.1.0] 在org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:670)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] 在org.eclipse.jetty.servlet.ServletHolder.initialize(ServletHolder.java:427)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] 在org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:760)〜[jetty-servlet-9.4.10.v20180503.jar!/:9.4.10.v20180503] 在org.springframework.boot.web.embedded.jetty.JettyEmbeddedWebAppContext $ JettyEmbeddedServletHandler.deferredInitialize(JettyEmbeddedWebAppContext.java:46)〜[弹簧引导2.0.2.RELEASE.jar /:2.0.2.RELEASE] at org.springframework.boot.web.embedded.jetty.JettyEmbeddedWebAppContext.deferredInitialize(JettyEmbeddedWebAppContext.java:36)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.web.embedded.jetty.JettyWebServer.handleDeferredInitialize(JettyWebServer.java:209)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] 在org.springframework.boot.web.embedded.jetty.JettyWebServer.start(JettyWebServer.java:141)〜[spring-boot-2.0.2.RELEASE.jar!/:2.0.2.RELEASE] ......还有18个
正在加载5.0.6.RELEASE
的版本org.springframework.web.servlet.handler.AbstractHandlerMapping
,它确实没有obtainApplicationContext
方法。
我必须关闭MongoAutoConfiguration
和WebMvcAutoConfiguration
才能达到这一点,但关闭EmbeddedWebServerFactoryCustomizerAutoConfiguration
似乎没有帮助。任何人都可以了解我可能会遇到什么问题吗?
答案 0 :(得分:0)
发现问题 - 该方法继承自spring上下文包中的org.springframework.context.support.ApplicationObjectSupport,我的版本较旧。啊