ruoyi-cloud集成knife4j

在ruoyi-cloud中使用knife4j

在ruoyi pom.xml文件中添加
            <!-- swagger增强配置 knife4j -->
            <dependency>
                <groupId>com.github.xiaoymin</groupId>
                <artifactId>knife4j-spring-boot-starter</artifactId>
                <version>${knife4j.version}</version>
            </dependency>
            <!--knife4j的UI-->
            <dependency>
                <groupId>com.github.xiaoymin</groupId>
                <artifactId>knife4j-micro-spring-boot-starter</artifactId>
                <version>${knife4j.version}</version>            </dependency>
在ruoyi-common-swagger,pom.xml文件中添加
        <!--swagger增强 knife4j-->
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-spring-boot-starter</artifactId>
        </dependency>
在ruoyi-gateway,pom.xml文件中 注释原来引入的swagger依赖,增加knife4j依赖
        <!-- Swagger -->
<!--        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>${swagger.fox.version}</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>${swagger.fox.version}</version>
        </dependency>
-->

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>


        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-micro-spring-boot-starter</artifactId>
        </dependency>
在nacos配置中心的ruoyi-gateway-dev.yml,文件中添加配置
#knife4j配置
knife4j:
  basic:
    enable: false
  enable: true
  #增强配置
  setting:
    enableSwaggerModels: true
    enableDocumentManage: true
    enableHost: true
    enableHostText: http://localhost
    enableRequestCache: false
    enableFilterMultipartApis: true
    enableFilterMultipartApiMethodType: POST
    language: zh-CN

完成上面的配置后 启动RuoYiGatewayApplication服务访问 http://localhost:8080/doc.html 即可看到接口文档页面。启动对应模块即可在接口文档中查看模块的接口信。
在这里插入图片描述

注:
1,需要访问的服务需要在ruoyi-gateway-dev.yml中的spring.cloud.gateway.routes中配置相关参数。
2,想查看接口信息需要添加对应的注解:@ApiModelProperty,@ApiModel,@Api,@ApiOperation等。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值