http://xiangai.taobao.com
http://shop148612228.taobao.com

SpringBoot配置swagger(3.0.0)及遇到的Bug(spring-plugin-core导包冲突)

SpringBoot配置swagger(3.0.0)及遇到的Bug
一、swagger的配置
1、在pom.xml里添加swagger依赖,如下:

<!-- 配置swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
1
2
3
4
5
6
2、在springboot启动类上添加@EnableOpenApi注解

//开启swagger api
@EnableOpenApi
@SpringBootApplication
public class EnglishwebApplication {

public static void main(String[] args) {
SpringApplication.run(EnglishwebApplication.class, args);
}

}
1
2
3
4
5
6
7
8
9
10
3、启动springboot项目后,访问http://localhost:8888/swagger-ui/index.html,如需改变端口号和项目名http://localhost:[端口号]/[项目名]/swagger-ui/index.html。

 

4、给Controller接口添加类和方法说明,其中api类说明@Api(tags = “后台管理系统用户管理”),api方法说明@ApiOperation(“用户登录”),更多注解请参考swagger文档。

二、遇到的Bug
启动项目的时候swagger3.0.0和spring-plugin-core导包冲突

The following method did not exist:

org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;)Ljava/util/Optional;

The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

jar:file:/G:/dev/apache-maven-3.6.3/repository/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:/G:/dev/apache-maven-3.6.3/repository/org/springframework/plugin/spring-plugin-core/1.2.0.RELEASE/spring-plugin-core-1.2.0.RELEASE.jar
1
2
3
4
5
6
7
8
9
10
11
解决方法:在pom.xml中添加如下依赖,强制更改spring-plugin-core版本成为2.0.0

<!-- 更改spring-plugin-core版本,解决与swagger导包冲突问题 -->
<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>
1
2
3
4
5
6
7
8
9
10
11

————————————————
版权声明:本文为CSDN博主「Luke.Du」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_45369827/article/details/113809907

posted @ 2021-04-06 21:56  万事俱备就差个程序员  阅读(4640)  评论(0编辑  收藏  举报

http://xiangai.taobao.com
http://shop148612228.taobao.com
如果您觉得对您有帮助.领个红包吧.谢谢.
支付宝红包
微信打赏 支付宝打赏