Idea导入SpringBoot项目时,Springboot通过application启动报错

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-04-25 11:25:29.394 ERROR 24572 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545) ~[spring-context-5.2.10.RELEASE.jar:5.2.10.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405) [spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at com.wang.haiNanYeWu.HnyewuApplication.main(HnyewuApplication.java:18) [classes/:na]
Caused by: org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.getWebServerFactory(ServletWebServerApplicationContext.java:205) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:177) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:158) ~[spring-boot-2.3.5.RELEASE.jar:2.3.5.RELEASE]
	... 9 common frames omitted

Springboot通过application启动报错
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException: Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

解决方案在这里插入图片描述
因为本地习惯用springboot,但是线上运维配的是tomcat 部署war包的方式。本地跑的时候注释掉pom.xml里spring-boot-starter-tomcat。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在将idea导入springboot项目后,可以按照以下步骤进行配置和运行。 1. 打开idea,选择File -> Open -> 选择springboot项目的根目录并打开。 2. 在项目根目录下找到pom.xml文件,这是Maven项目的配置文件。确认项目的依赖项和插件是否正确配置。如果存在任何误或缺少的依赖项,可以在该文件中进行修改。 3. 打开src/main/resources/application.properties或application.yml文件,这是springboot项目的配置文件,可以在其中进行项目的相关配置。根据项目需求,可以设置数据库连接、端口号等。 4. 在idea的右侧的"Maven Projects"视图中,展开项目,找到"Lifecycle"选项,然后双击"package"以构建项目,确保项目可以成功编译。 5. 打开主启动类,通常命名为XXXApplication.java,确保该类上有@SpringBootApplicatio注解。 6. 点击idea顶部的菜单栏中的"Run",选择"Edit Configurations",然后点击"+"按钮添加一个新的配置。选择"Spring Boot",填写"Name"(配置名称)和"Main Class"(主启动类)。其他配置项根据项目的需要选择填写或者直接使用默认配置即可。 7. 点击"Apply"和"OK"来保存配置。 8. 点击idea顶部的菜单栏中的"Run",选择刚刚配置好的运行配置来启动项目。 9. 启动后,在idea的控制台中可以看到项目启动日志。 10. 使用浏览器或者其他HTTP请求工具,访问项目的URL,进行测试和调试。 通过以上几个步骤,我们可以成功配置并运行springboot项目。如果项目还有其他的需要配置的地方,可以根据具体情况进行修改。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值