您现在的位置是:网站首页 > 代码编程 > JAVA开发JAVA开发
【原】Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean
不忘初心 2021-12-04 围观() 评论() 点赞() 【JAVA开发】
简介:Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean,这就是典型的tomcat依赖没处理好导致的问题。
由于springboot
项目内嵌了tomcat
,所以一般都会将项目打包成jar
包来进行发布,而并非以前的war
包,但是公司有一个项目依旧将springboot
项目打成war
包,然后丢到tomcat容器中运行,这样就需要兼容本地启动调试和线上运行,涉及到tomcat依赖的地方就需要格外注意,一不小心就会导致有一边儿会启动失败。
整理之前的笔记,发现以前还真碰到过这个问题,本地能正常启动,但是发布到线上的时候就报错:Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean,这就是典型的tomcat
依赖没处理好导致的问题。
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2020-12-18 09:14:06,263 default [background-preinit] INFO o.h.v.i.u.Version 898 - HV000001: Hibernate Validator 6.1.5.Final
2020-12-18 09:14:06,301 default [main] INFO c.g.l.Application 936 - Starting Application on LAPTOP-9J4HVAON with PID 2568 (D:\workspace_idea\logistics\target\classes started by Administrator in D:\workspace_idea\logistics)
2020-12-18 09:14:06,301 default [main] INFO c.g.l.Application 936 - The following profiles are active: dev
2020-12-18 09:14:07,692 default [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate 2327 - Multiple Spring Data modules found, entering strict repository configuration mode!
2020-12-18 09:14:07,695 default [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate 2330 - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2020-12-18 09:14:07,760 default [main] INFO o.s.d.r.c.RepositoryConfigurationDelegate 2395 - Finished Spring Data repository scanning in 43ms. Found 0 Redis repository interfaces.
2020-12-18 09:14:08,198 default [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker 2833 - Bean 'redisConfig' of type [com.gude.logistics.config.RedisConfig$$EnhancerBySpringCGLIB$$dfa45a1c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-18 09:14:08,221 default [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker 2856 - Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@2ffb3aec' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-18 09:14:08,226 default [main] INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker 2861 - Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-12-18 09:14:08,347 default [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext 2982 - Exception encountered during context initialization - cancelling refresh attempt: 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.
2020-12-18 09:14:08,357 default [main] INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener 2992 -
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-12-18 09:14:08,368 default [main] ERROR o.s.b.SpringApplication 3003 - 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)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at com.gude.logistics.Application.main(Application.java:12)
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)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:177)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:158)
... 9 common frames omitted
因为线上已经使用了tomcat外部容器了,所以在打war
包的时候就不在需要tomcat相关的jar
包了,否则就会冲突。
<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>
搞定,收工!
看完文章,有任何疑问,请加入群聊一起交流!!!
很赞哦! ()
相关文章
- JPA报错“No identifier specified for entity”的原因
- springboot整合jpa启动报错'hibernate.dialect' not set
- springboot使用jackson处理时间碰到的两个坑
- Linux不使用tomcat搭建springboot服务图文教程
- springboot项目提示“Failed to determine a suitable driver class”
- springboot打war包,部署到外部tomcat
- springboot项目在mac下启动特别慢
- 使用idea搭建springboot项目图文教程
- Spring Boot配置Druid数据源和使用教程
- springboot连接mysql报错“java.lang.IllegalArgumentException: HOUR_OF_DAY: 2 -> 3”
标签云
猜你喜欢
- IntelliJ IDEA 2019.2已经可以利用补丁永久破解激活了
- IntelliJ IDEA 2019.3利用补丁永久破解激活教程
- IntelliJ IDEA高版本最灵活的永久破解激活方法(含插件激活,时长你说了算)
- Jetbrains全家桶基于ja-netfilter的最新破解激活详细图文教程
- IntelliJ IDEA 2022.1永久破解激活教程(亲测可用,持续更新)
- 分享几个正版 IntelliJ IDEA 激活码(破解码、注册码),亲测可用,持续更新
- ja-netfilter到底需不需要mymap,2021.3.2版本激活失效?
- 如何激活idea2022.1及以上版本中的插件(亲测可用)
- 【史上最全】IntelliJ IDEA最新2022.1版本安装和激活视频教学(含插件)
- IntelliJ IDEA 2022.2 版本最新2099年永久激活方法,亲测可用,也可以开启新UI了。
站点信息
- 网站程序:spring + freemarker
- 主题模板:《今夕何夕》
- 文章统计:篇文章
- 标签管理:标签云
- 微信公众号:扫描二维码,关注我们