Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServlet

package com.xxx.app;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.xxx.listener.StartupListener;

@SpringBootApplication
@EnableAutoConfiguration
@EnableTransactionManagement
public class SpringbootStartApplication {
	public static void main(String[] args) {
		SpringApplication app = new SpringApplication(StartupListener.class);// 参数应该是 SpringbootStartApplication.class
		app.addListeners(new StartupListener());
		app.run(args);
	}
}

由于一开始 StartupListener.class 命名跟   SpringbootStartApplication比较相似,所以一直没看出来

Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean 是一个报错信息,提示在启动ServletWebServerApplicationContext时缺少了ServletWebServerFactory bean。 解决这个问题的方法有多种,以下是一些常见的解决方案: 1. 确保在应用程序的配置文件中正确配置了ServletWebServerFactory bean。检查应用程序的配置文件,例如application.properties或application.yml,确保已经定义了合适的服务器工厂bean。例如,对于Spring Boot应用程序,可以在配置文件中添加以下内容: ```properties server.servlet.container.factory = org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory ``` 或者在配置类中使用`@EnableWebMvc`注解来启用Web MVC并配置合适的ServletWebServerFactory bean。 2. 检查项目的依赖是否正确。确保项目中包含了正确版本的Spring Boot和相关的依赖库。可以通过使用合适的构建工具(如Maven或Gradle)来管理项目的依赖。 3. 检查应用程序的代码是否正确。可能是由于代码中的错误导致了这个问题。请检查相关的代码,特别是与ServletWebServerApplicationContext和ServletWebServerFactory相关的代码,确保它们正确地配置和使用。 需要注意的是,以上解决方案只是一些常见的方法,具体的解决方案可能因应用程序的具体情况而有所不同。如果以上方法无法解决问题,建议查阅相关的文档或向开发社区寻求帮助,以获取更具体的解决方案。<span class="em">1</span><span class="em">2</span><span class="em">3</span><span class="em">4</span>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值