spring cloud 踩坑记

博客讲述了在使用Spring Cloud Eureka时遇到的启动报错问题,错误源于Servlet-api版本不匹配。尝试了网上常见的解决方案如升级Servlet-api版本和回退Spring Boot版本,但问题仍未解决。最终发现原因是spring-cloud-dependencies未放在dependencyManagement标签下,导致eureka-core引用了错误的Servlet-api版本。修复方法是确保spring-cloud-dependencies在dependencyManagement中,以正确管理依赖版本。
摘要由CSDN通过智能技术生成

eureka启动报错:

The following method did not exist:

    'java.lang.String javax.servlet.ServletContext.getVirtualServerName()'

The method's class, javax.servlet.ServletContext, is available from the following locations:

    jar:file:/F:/localRepository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar!/javax/servlet/ServletContext.class
    jar:file:/F:/localRepository/org/apache/tomcat/embed/tomcat-embed-core/9.0.29/tomcat-embed-core-9.0.29.jar!/javax/servlet/ServletContext.class

It was loaded from the following location:

    file:/F:/localRepository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar

网上解决办法:

1.排除本地Servlet-api 2.5, 使用Servlet-api 3.1.0以及之后的版本中才有getVirtualServerName。

<dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      &
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值