springboot2搭建工程时遇到的棘手问题

典型问题

引入的jar并未按照pom中的定义来

现象

在这里插入图片描述

导致的问题

导致内置tomcat启动时一直报如下异常:

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.

排查步骤:

  1. spring-boot-starter-tomcat的源文件发下实际依赖的是9.0.27如下图:

在这里插入图片描述
2. spring-boot-dependencies 的定义也是9.0.27:

在这里插入图片描述

  1. 经过排查发现项目父pom中也定义的有tomcat.version和spingboot 父pom中有冲突:导入jar依赖冲突

        <properties>
        ....
        ...
         <tomcat.version>8.0.30</tomcat.version>
        </properties>
    

    解决:删掉本项目中父Pom中定义的 和springboot有冲突的properties;

    总结:尽量不要和框架里定义的properties相冲突如springboot中spring-boot-dependencies定义的properties;如果出现jar包冲突且点进去发现和定义的不一致,排查下是否有其他项目依赖覆盖了期望的依赖;jar冲突引发各种奇葩问题但使用 idea 的maven helper插件能帮我们一步步分析排除。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值