码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • idea spring boot java maven 依赖重复报错解决


    依赖重复报错


    APPLICATION FAILED TO START


    Description:
    An attempt was made to call a method that does not exist. The attempt was made from the following location:
    org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1355)
    The following method did not exist:
    javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;

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

    jar:file:/E:/Tool/maven/maven-repository/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar!/javax/servlet/ServletContext.class
    jar:file:/E:/Tool/maven/maven-repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.41/tomcat-embed-core-9.0.41.jar!/javax/servlet/ServletContext.class

    The class hierarchy was loaded from the following locations:

    javax.servlet.ServletContext: file:/E:/Tool/maven/maven-repository/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar

    Action:

    Correct the classpath of your application so that it contains a single, compatible version of javax.servlet.ServletContext
    Process finished with exit code 1

    分析:
    编译时无报错,运行时报错。

    从上面看是由于多个依赖 同时包含 ServletContext.class 所致。

    包含该类的jar文件分别是 servlet-api-2.3.jar 和 tomcat-embed-core-9.0.29.jar

    我们需要这里要排除 servlet-api-2.3.jar

    解决:

    1、打开项目依赖关系图
    2、查找依赖
    在这里插入图片描述

    3、追溯项目依赖,直接点进去就可以

    查找是哪些依赖引入了servlet-api-2.3.jar,通过点击箭头,往上追溯,一直到我们自己的依赖

    4、排除依赖

    <dependency>
        <groupId>com.octo.captchagroupId>
        <artifactId>jcaptchaartifactId>
        <version>1.0version>
        <exclusions>	//排除
            <exclusion>
                <groupId>javax.servletgroupId>
                <artifactId>servlet-apiartifactId>
            exclusion>
        exclusions>
    dependency>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    5、再次编译后启动

  • 相关阅读:
    Structured Streaming Source
    如何验证高压放大器的性能好坏呢
    怎么画深度优先生成树和广度优先生成树【简答题】
    axios基本用法、axios如何发起网络请求?如何二次封装axios?
    Impact of Problem Decomposition on Cooperative Coevolution
    【Vue】Vue2创建移动端项目实战教程,创建移动端项目保姆级教程,接上一篇创建Vue2项目(下)
    剑指 Offer 18. 删除链表的节点
    [附源码]Python计算机毕业设计Django校园招聘系统
    微电网两阶段鲁棒优化问题(Matlab代码实现)
    影片自由,丝滑流畅,Docker容器基于WebDav协议通过Alist挂载(百度网盘/阿里云盘)Python3.10接入
  • 原文地址:https://blog.csdn.net/weixin_41714868/article/details/128009995
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号