zoukankan      html  css  js  c++  java
  • 项目启动报错:Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

    org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
    	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    	at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    	at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) [spring-boot-1.5.9.RELEASE.jar:1.5.9.RELEASE]
    	at com.wukong.atp.registrycenter.RegistryCenterApplication.main(RegistryCenterApplication.java:26) [classes/:na]
    

      背景:新公司,入职后跑工程的时候;项目是springboot的,是有内置容器的;查看pom,发现排除了

                   <dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    			<exclusions>
    				<exclusion>
    					<groupId>org.springframework.boot</groupId>
    					<artifactId>spring-boot-starter-tomcat</artifactId>
    				</exclusion>
                          </exclusions>
               </dependency>
    

      问题是为什么要排除呢?后面发现pom中还有另外一个依赖

                     <dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-undertow</artifactId>
    			<scope>provided</scope>
    		</dependency>
    

      这个是undertow的依赖,undertow是一个高性能的web容器;像上面的,排除了tomcat,用undertow;那应该没问题啊;后面发现问题:

    <scope>provided</scope>  这里,scope是provided。  改成compile就可以了;或者删掉,因为默认就是compile

  • 相关阅读:
    Android在onCreate()中获得控件尺寸
    Java根据出生年月日获取到当前日期的年月日
    Oracle 取随机数
    filter,orderBy等过滤器
    ng-repeat 指令
    三元表达式、逻辑表达式 与 &&、||的妙用
    ng-switch 指令
    sublime text 3.0 安装 HTML-CSS-JS Prettify
    JS相关环境搭建:Nodejs、karma测试框架、jsDuck、Express
    关于VSS上的项目源码管理的注意问题
  • 原文地址:https://www.cnblogs.com/mmh760/p/13559503.html
Copyright © 2011-2022 走看看