分布式架构,编写了一个公共的SwaggerConfiguration配置类,在不抽取Feign接口的时候直接在本模块定义远程调用接口不会出现下面的报错,当通过抽取的API接口模块进行调用的时候运行项目就出现这样的情况
***************************
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:
com.zcl.dkbj.service.swagger.SwaggerConfiguration.groupRestApi(SwaggerConfiguration.java:40)
The following method did not exist:
springfox.documentation.builders.RequestHandlerSelectors.basePackage(Ljava/lang/String;)Ljava/util/function/Predicate;
The method's class, springfox.documentation.builders.RequestHandlerSelectors, is available from the following locations:
jar:file:/usr/local/apache-maven-3.8.6/Repository/io/springfox/springfox-core/2.7.0/springfox-core-2.7.0.jar!/springfox/documentation/builders/RequestHandlerSelectors.class
It was loaded from the following location:
file:/usr/local/apache-maven-3.8.6/Repository/io/springfox/springfox-core/2.7.0/springfox-core-2.7.0.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of springfox.documentation.builders.RequestHandlerSelectors
我的尝试解决方法就是在单独的模块中定义Feign的远程调用接口而不是抽取出独立的模块进行依赖注入调用,当时这样耦合度比较高
这个错误消息表明,在你的程序中,有一个类调用了一个不存在的方法。在这种情况下,在 SwaggerConfiguration 类的 groupRestApi 方法中调用了 springfox.documentation.builders.RequestHandlerSelectors 类中不存在的 basePackage 方法。
这个错误可能是由于你使用了不兼容版本的springfox包导致的。
解决方案可能包括:
检查你项目中所有依赖的springfox版本,确保它们都是相同且兼容的版本
使用合适的版本依赖管理工具(如maven或gradle),强制使用一个特定的版本
重新下载和安装依赖的springfox包,确保它们是最新版本或与你使用的其他包兼容的版本
如果问题仍然存在,可能需要查看项目的构建脚本和配置文件,检查是否有其他引用了不同版本的springfox包。
需要根据具体的项目环境来解决这个问题,如果上面的建议都不起作用,建议查看项目的构建脚本和配置文件,确保依赖的springfox包版本是正确和兼容的。