异常描述
启动SpringBoot项目控制台报了关于undertow NoClassDefFoundError
的异常,详细报错信息如下所示:
org.springframework.context.ApplicationContextException: Unable to start embedded container;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'undertowEmbeddedServletContainerFactory'
defined in class path resource [org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration$EmbeddedUndertow.class]:
Post-processing of merged bean definition failed; nested exception is java.lang.NoClassDefFoundError: io/undertow/servlet/api/DeploymentManager
重点最后一句:java.lang.NoClassDefFoundError: io/undertow/servlet/api/DeploymentManager
解决方法
添加`undertow-servlet的依赖pom即可解决,pom文件内容如下:
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-servlet</artifactId>
</dependency>
然后查看导入的依赖发现已经拥有DeploymentManager这个接口,重新运行项目即可。