Eureka集成过程常见异常

本文详细分析了Eureka集成过程中遇到的8种常见异常,包括Servlet类冲突、ConfigurationPropertiesBean找不到、内部Java编译错误等,并提供了相应的解决方法,如调整Spring Boot和Spring Cloud版本匹配、排除依赖冲突等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

异常1:jar包冲突类冲突ServletContext.class

An attempt was made to call the method javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String; but it does not exist. Its class, javax.servlet.ServletContext, is available from the following locations: 尝试调用方法javax.servlet.ServletContext.getVirtualServerName();但它并不存在。

它的类,javax.servlet。ServletContext,可从以下位置获得: jar:file:/E:/Software/apache-maven-3.5.3/repository/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.jar!/javax/servlet/ServletContext.class jar:file:/E:/Software/apache-maven-3.5.3/repository/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar!/javax/servlet/ServletContext.class jar:file:/E:/Software/apache-maven-3.5.3/repository/org/apache/tomcat/embed/tomcat-embed-core/8.5.39/tomcat-embed-core-8.5.39.jar!/javax/servlet/ServletContext.class It was loaded from the following location:

它是从以下地点加载的: file:/E:/Software/apache-maven-3.5.3/repository/org/mortbay/jetty/servlet-api-2.5/6.1.14/servlet-api-2.5-6.1.14.jar Action: Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext

原因:从错误信息看出,在tomcat-embed-core-9.0.17.jar和servlet-api-2.5.jar里面都有javax.servlet.ServletContext, 而这个类在eureka中使用默认用了servlet-api-2.5.jar进行。经过查看发现,servlet-api-2.5.jar是eureka里面引进来的

解决:

方法1(不推荐)

Project Structure----Modules—微服务----Dependences

重复依赖仅保留一个其余改为Test或删除,删除或者改为test

方法2

添加:
<exclusion>
    <groupId>org.apache.shiro</groupId>
    <artifactId>shiro-quartz</artifactId>
</exclusion>
例如:
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    <version>2.1.3.RELEASE</version>
    <exclusions>
        <exclusion>                
            <artifactId>servlet-api
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值