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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

万事俱备,就差一个程序员了

谢谢您,赏俺根辣条,尝尝鲜.谢

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值