1. 程式人生 > >Spring Boot常見問題(二)Unable to start embedded container; nested exception is java.lang.NoSuchMethodErro

Spring Boot常見問題(二)Unable to start embedded container; nested exception is java.lang.NoSuchMethodErro

問題描述:通過Spring Boot官方提供的方式,寫出如下HelloWorld程式碼。

@Controller
@EnableAutoConfiguration
public class HelloWorld {
    @RequestMapping("/wu")
    @ResponseBody
    String home() {
        return "Hello World!";
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(HelloWorld.class, args);
    }
}

在執行main()方法時,丟擲如下異常。

org.springframework.context.ApplicationContextException: Unable to start embedded container; 
   nested exception is java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
    at org.springframework.boot
.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.10.RELEASE.jar:4.3.10
.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at dolphin.springboot.controller.HelloWorld.main(HelloWorld.java:30) [classes/:na] Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner$Tomcat8TldSkipSetter.setSkipPattern(SkipPatternJarScanner.java:106) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.setPatternToTomcat8SkipFilter(SkipPatternJarScanner.java:61) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.<init>(SkipPatternJarScanner.java:56) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.apply(SkipPatternJarScanner.java:87) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.prepareContext(TomcatEmbeddedServletContainerFactory.java:209) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:178) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134) ~[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] ... 8 common frames omitted

經檢查,在org.apache.tomcat.util.scan.StandardJarScanner類中存在setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)方法,並且親自測試,可以正常使用。而丟擲異常卻說沒有此方法。

分析原因:1.存在重複的jar包。2.版本調整帶來的影響。

  經排查,發現MyEclipse Tomcat v7.0 Runtime Libraries包,和Maven Dependencies包中均包含org.apache.tomcat.util.scan.StandardJarScanner類。
這裡寫圖片描述

於是,取消MyEclipse Tomcat v7.0 Runtime Libraries包,執行正常。

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.6.RELEASE)

2017-09-09 09:27:03.646  INFO 6400 --- [           main] d.springboot.controller.HelloWorld       : Starting HelloWorld on DESKTOP-N8HPR69 with PID 6400 (started by wushuai in C:\Users\wushuai\Workspaces\MyEclipse for Spring 2014\springboot Maven Webapp)
2017-09-09 09:27:03.648  INFO 6400 --- [           main] d.springboot.controller.HelloWorld       : No active profile set, falling back to default profiles: default
2017-09-09 09:27:03.679  INFO 6400 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot[email protected]5680a576: startup date [Sat Sep 09 09:27:03 CST 2017]; root of context hierarchy
2017-09-09 09:27:04.734  INFO 6400 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2017-09-09 09:27:04.743  INFO 6400 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2017-09-09 09:27:04.744  INFO 6400 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.16
2017-09-09 09:27:04.820  INFO 6400 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2017-09-09 09:27:04.820  INFO 6400 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1143 ms
2017-09-09 09:27:04.952  INFO 6400 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2017-09-09 09:27:04.956  INFO 6400 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-09-09 09:27:04.956  INFO 6400 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-09-09 09:27:04.956  INFO 6400 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-09-09 09:27:04.956  INFO 6400 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2017-09-09 09:27:05.266  INFO 6400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot[email protected]5680a576: startup date [Sat Sep 09 09:27:03 CST 2017]; root of context hierarchy
2017-09-09 09:27:05.324  INFO 6400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/wu]}" onto java.lang.String dolphin.springboot.controller.HelloWorld.home()
2017-09-09 09:27:05.327  INFO 6400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2017-09-09 09:27:05.328  INFO 6400 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2017-09-09 09:27:05.356  INFO 6400 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-09-09 09:27:05.356  INFO 6400 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-09-09 09:27:05.398  INFO 6400 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2017-09-09 09:27:05.580  INFO 6400 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-09-09 09:27:05.650  INFO 6400 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-09-09 09:27:05.655  INFO 6400 --- [           main] d.springboot.controller.HelloWorld       : Started HelloWorld in 2.298 seconds (JVM running for 2.534)

相關推薦

Spring Boot常見問題Unable to start embedded container; nested exception is java.lang.NoSuchMethodErro

問題描述:通過Spring Boot官方提供的方式,寫出如下HelloWorld程式碼。 @Controller @EnableAutoConfiguration public class HelloWorld { @RequestMapping(

Spring Boo報錯Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org

轉載地址:https://www.cnblogs.com/wushuai2014/p/7497206.html 問題描述:通過Spring Boot官方提供的方式,寫出如下HelloWorld程式碼。 org.springframework.context.ApplicationContex

springBoot報錯Unable to start embedded container; nested exception is org.springframework.context.Appl

今天樓主在做一個maven+springBoot的簡單專案的時候,發現報了 Unable to start embedded container; nested exception is org.springframework.context.Appl....的錯誤, 經過

SpringBoot啟動報錯" Unable to start embedded container; nested exception is org.springframework.beans.fa

SpringBoot啟動報如下異常: Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'deb

Spring Boot學習

div 自動 blog release width spring figure 學習 toc 基於Spring Boot創建的maven項目 1、application.properties或者application.yml:全局配置文件 作用:主要用來配置數據庫連接、日

Jenkins+Docker自動化部署Spring boot專案 搭建docker私庫Harbor

前言 docker映象的push、pull都需要映象庫。現在不少大廠提供免費的映象庫,如docker hub,163 hub,也可以自己搭建一個私有映象庫。我用了vmware公司開源的harbor作為docker私有庫,相比docker官方提供的私有庫regi

Spring Boot學習:mybatis + druid + 多資料來源自動切換

一、簡介 閒言碎語不多說:專案中要用到多資料來源分別管理資料,主資料來源儲存正式資料,從資料來源儲存預載入的資料並完成預校驗。 二、環境準備 eclipse + maven + Spring Boot + mybatis + oracle 三、程式碼改造 pom

Spring Boot 學習特點

一、SpringApplication banner,就是啟動時輸出的資訊,可以在classpath下新增 banner.txt,或者設定 banner.location 來指向特定的檔案。(預設編碼utf-8,或者通過banner.charset指定) 除了txt,你還可以使用 banner.gif (jp

Spring-boot參考

依賴管理 繼承starter parent <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boo

Spring Boot 啟動 Environment 加載

mman figure 3.2 params eba set 內容 hash gprof Spring Boot 啟動(二) Environment 加載 Spring 系列目錄(https://www.cnblogs.com/binarylei/p/10198698.ht

Spring Boot 啟動 配置詳解

ner sys 記錄 標準 () 系統屬性 code 不同 .profile Spring Boot 啟動(二) 配置詳解 Spring 系列目錄(https://www.cnblogs.com/binarylei/p/10198698.html) Spring Boot

spring-boot-route讀取配置檔案的幾種方式

Spring Boot提供了兩種格式的配置檔案,分別是`properties` 和 `yml`。Spring Boot最大的特點就是自動化配置,如果我們想修改自動化配置的預設值,就可以通過配置檔案來指定自己伺服器相關的引數。 配置檔案集約管理了配置資訊,如果把配置引數寫到Java程式碼中,維護起來非常不方便

解決springboot啟動失敗問題:Unable to start embedded container;

應該 create exception illegal cep listener cli use log 全部報錯內容如下: org.springframework.context.ApplicationContextException: Unable to start e

啟動SpringBoot嵌入的tomcat導致不能啟動 unable to start embedded container的錯誤

啟動SpringBoot嵌入的tomcat導致不能啟動   <!-- tomcat 的支援.--> <dependency> <groupId>org.springframework.boot</groupId

啟動springboot專案報錯Unable to start embedded container

後端技術: mave,springbootDataJpa,Springboot,Log4j,Spring,Hibernate,Netty,JWT,jpush,Jetty / tomcat[與tomcat相比,更加輕量級],httpclient等 報錯資訊如下:   看了下

Failed to instantiate No default constructor found; nested exception is java.lang.NoSuchMethodExcept

從網頁接受引數,引數多的情況下一般會定義一個類,來裝這些引數,比如UserParam這個類就是裝網頁裡面轉過來的 id、username、telephone等資訊。但是會發現在修改的時候會報如下錯誤。 報錯資訊如下: org.springframework.beans.BeanInsta

spring關於nested exception is java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/exc/Inval

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.Re

Spring與MyBatis整合錯誤:nested exception is java.lang.NoClassDefFoundError

最近在學習整合Spring與MyBatis時,出現了以下異常: Error creating bean with name 'sqlSessionFactoryBean' defined in class path resource [application-mybatis

Failed to start bean 'stompBrokerRelayMessageHandler'; nested exception is java.lang.NoClassDefFoundError: reactor/io/codec/Codec

最新版本的Spring需要reactor 2.0,看看你的POM有一個明確的1.1.6依賴。 解決: <dependency> <groupId>org.projectreactor</groupId> <artifactId>reac

nested exception is java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.()V from class org.hibernat

今天配置struts2+hibernate3+spring2時出現這種問題,控制檯輸出了 java.lang.IllegalAccessError: tried to access method net.sf.ehcache.CacheManager.<init>