SpringBoot 集成Swagger3,spring-plugin-core提示不匹配
今天使用SpringBoot集成Swagger 输出如下错误信息:
*************************** APPLICATION FAILED TO START *************************** Description: An attempt was made to call the method org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;)Ljava/util/Optional; but it does not exist. Its class, org.springframework.plugin.core.PluginRegistry, is available from the following locations: jar:file:/C:/programs/maven/localHouse/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class It was loaded from the following location: file:/C:/programs/maven/localHouse/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar Action: Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry
按照错误提示,怀疑是包冲突,于是执行mvn dependency:tree >tree.log进行maven依赖查看,结果spring-plugin-core 1.2.0-RELEASE只有springfox在使用(即Swagger3),所以并不存在冲突的问题
解决方案:强制将依赖版本升级到2.0,问题解决
<!-- swagger3 接口文档生成器 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> <exclusions> <exclusion> <groupId>org.springframework.plugin</groupId> <artifactId>spring-plugin-core</artifactId> </exclusion> <exclusion> <groupId>org.springframework.plugin</groupId> <artifactId>spring-plugin-metadata</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework.plugin</groupId> <artifactId>spring-plugin-core</artifactId> <version>2.0.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.plugin</groupId> <artifactId>spring-plugin-metadata</artifactId> <version>2.0.0.RELEASE</version> </dependency>