• 项目启动报错: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

  • 相关阅读:
    python图像仿射变换实战-提取手写数字图片样本
    详解增强算术赋值:“-=”操作是怎么实现的?
    Pycharm激活码,2020最新Pycharm永久激活码!
    Python爬虫视频教程百度云网盘免费分享
    尚学堂高淇Python400集全套视频教程百度云网盘分享
    Python入门教程哪个好?看看这套怎么样!
    python框架Django实战商城项目之工程搭建
    Python入门书籍电子版PDF百度云网盘免费下载
    廖雪峰老师Python教程及配套视频教程
    manjaro(arch)里的vbox 安装centos7后,centos无法联网的解决办法
  • 原文地址:https://www.cnblogs.com/mmh760/p/13559503.html
Copyright © 2020-2023  润新知