zoukankan      html  css  js  c++  java
  • SpringBoot结合swagger2快速生成简单的接口文档

    1. pom.xml中加入依赖

            <dependency>
                <groupId>com.spring4all</groupId>
                <artifactId>swagger-spring-boot-starter</artifactId>
                <version>1.8.0.RELEASE</version>
            </dependency>
    

    2. 在启动类(即带@SpringBootApplication这个注解的类)上添加@EnableSwagger2Doc注解

    3. 在application.properties中配置如下

    swagger.enabled=true
    swagger.title=spring-boot-mybatis module api
    swagger.description=Starter for swagger 2.x
    swagger.license=Apache License, Version 2.0
    swagger.licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.html
    swagger.termsOfServiceUrl=https://github.com/pbw123/spring-boot-demo
    swagger.contact.name=mqXu
    swagger.contact.url=https://www.jianshu.com/u/2f60beddf923
    swagger.contact.email=2635225112@qq.com
    swagger.base-package=com.springboot.mybatis.controller
    swagger.base-path=/**
    swagger.exclude-path=/error, /ops/**
    

    经我多次尝试application.properties中不加任何swagger配置也可生成文档进行正常测试


    另一种用swagger自动生成文档的方式请前往

    个人网站

  • 相关阅读:
    javaee_正则表达式基础和常用表达式
    hello2源代码分析
    servlet_filterj简介
    hello1的web.xml解析
    Annotation
    注入(Injection)
    容器(Container)
    Building Tool(Maven/Gradle)
    JavaWeb的历史与发展趋势
    Build Tools
  • 原文地址:https://www.cnblogs.com/panbingwen/p/10765263.html
Copyright © 2011-2022 走看看