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

posted on 2020-08-25 14:26  哈皮的玩偶  阅读(2576)  评论(0编辑  收藏  举报