小工具知识网

当前位置: 首页 > 行业知识 > 问题1-spring-boot版本和org.springframework的spring-web兼容的版本

行业知识

问题1-spring-boot版本和org.springframework的spring-web兼容的版本

2026-11-03 09:54:43 来源:互联网转载

报错问题如下:

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

  org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.createHandlerMethod(AbstractHandlerMethodMapping.java:345)

The following method did not exist:

    org.springframework.web.method.HandlerMethod.(Ljava/lang/String;Lorg/springframework/beans/factory/BeanFactory;Lorg/springframework/context/MessageSource;Ljava/lang/reflect/Method;)V

The calling method's class, org.springframework.web.servlet.handler.AbstractHandlerMethodMapping, was loaded from the following location:

    jar:file:/F:/JAVA/MavenInstall/maven-Repository/org/springframework/spring-webmvc/5.3.23/spring-webmvc-5.3.23.jar!/org/springframework/web/servlet/handler/AbstractHandlerMethodMapping.class

The called method's class, org.springframework.web.method.HandlerMethod, is available from the following locations:

    jar:file:/F:/JAVA/MavenInstall/maven-Repository/org/springframework/spring-web/5.3.1/spring-web-5.3.1.jar!/org/springframework/web/method/HandlerMethod.class

The called method's class hierarchy was loaded from the following locations:

    org.springframework.web.method.HandlerMethod: file:/F:/JAVA/MavenInstall/maven-Repository/org/springframework/spring-web/5.3.1/spring-web-5.3.1.jar

 

===

具体报错原因

Correct the classpath of your applicat ion so that it contains compatible versions of the classes org.springframework.web.servlet.handler.AbstractHandlerMethodMapping and org.springframework.web.method.HandlerMethod 

============

解决方法直接看!!!

【2、查询spring-boot版本和org.springframework的spring-web兼容的版本】

==========

1、解决过程

查询AI解决方法:

输入的问题:

Correct the classpath of your applicat ion so that it contains compatible versions of the classes org.springframework.web.servlet.handler.AbstractHandlerMethodMapping and org.springframework.web.method.HandlerMethod 报错的原因和解决方法

解释如下:

这个错误通常是由于在同一个项目中,引入了不同版本的 Spring Framework 库,导致其中某些类或方法不兼容而引起的。在你的情况下,是 org.springframework.web.servlet.handler.AbstractHandlerMethodMapping 和 org.springframework.web.method.HandlerMethod 这两个类的版本不兼容。

解决方法如下:

  1. 检查依赖项的版本: 检查你项目构建配置文件中的依赖项(例如 Maven 的 pom.xml 或 Gradle 的 build.gradle 文件),确保所有的 Spring Framework 依赖项都与兼容的版本对齐。确保 org.springframework.web.servlet 和 org.springframework.web 模块的版本匹配,并且没有冲突。

  2. 排除冲突的传递依赖项: 如果你使用的是像 Maven 这样的构建工具,你可以排除那些可能会引入不兼容的 Spring Framework 类库版本的传递依赖项。识别任何导致版本冲突的依赖项,并将其排除在你的项目之外。

  3. 更新 Spring Framework 版本: 考虑更新你的 Spring Framework 依赖项到一个支持所需构造函数的版本。这可能涉及更新构建配置文件中的版本号,并解决与其他库的潜在兼容性问题。

  4. 清理和重新构建: 在更改依赖项后,执行清理和重新构建你的项目,以确保所有依赖项都已正确解析,并且类路径包含所需类的兼容版本。

  5. 运行和测试: 调整类路径以包含 Spring Framework 的必要类的兼容版本后,运行你的应用程序并进行测试,以验证问题是否已解决。确保所有功能按预期工作,没有涉及缺失构造函数的方法调用错误。

按照以上步骤并确保你的应用程序的类路径包含 Spring Framework 所需的兼容类的版本,应该可以解决你遇到的“方法不存在”错误

====

尝试解决方法:

1、尝试用 AI提出的 【2、更新 Spring Framework 版本】

以前pom文件里面spring-boot版本和org.springframework的spring-web的版本

  当时idea自动引入的版本

 2.6.4                    org.springframework            spring-web            5.3.1        

2、查询spring-boot版本和org.springframework的spring-web兼容的版本

springboot和springframework版本依赖关系

3、成功方法:

更新springframework的spring-web版本

  2.6.13                    org.springframework            spring-web            5.3.16        

成功画面:

更新springframework版本后整个pom文件内容

    4.0.0    com.yupi    user-center    0.0.1-SNAPSHOT    user-center    Demo project for Spring Boot            1.8        UTF-8        UTF-8        2.6.13                            org.springframework.boot            spring-boot-starter            2.6.4                            org.mybatis.spring.boot            mybatis-spring-boot-starter            2.2.2                            com.baomidou            mybatis-plus-boot-starter            3.5.1                            mysql            mysql-connector-java            runtime                            org.apache.commons            commons-lang3            3.12.0                            org.springframework.boot            spring-boot-starter-test            test                            org.projectlombok            lombok            true                            junit            junit            4.13.2            test                            org.springframework            spring-web            5.3.16                            org.springframework.boot            spring-boot-starter-web                                                    org.springframework.boot                spring-boot-dependencies                ${spring-boot.version}                pom                import                                                                org.apache.maven.plugins                maven-compiler-plugin                3.8.1                                    1.8                    1.8                    UTF-8                                                        org.springframework.boot                spring-boot-maven-plugin                ${spring-boot.version}                                    com.yupi.usercenter.UserCenterApplication                    true                                                                            repackage                                                    repackage                                                                                    

上一篇:应用服务器怎么部署?

下一篇:宠物救助系统|基于Springboot和vue的流浪猫狗救助救援系统设计与实现(源码+数据库+文档)