在线生成接口文档

2018-10-26  本文已影响0人  一块没梦想的海绵宝宝

1.添加依赖

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

2.增加注解

@SpringBootApplication
@EnableSwagger2Doc
public class SpringDataJpaApplication {

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

3.参数配置示例

swagger.enabled=true
swagger.title=spring-data-jpa module
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/dyc87112/spring-boot-starter-swagger
swagger.contact.name=RanRan Tao
swagger.contact.url=https://www.jianshu.com/u/822585e5c69a
swagger.contact.email=16422802@qq.com
swagger.base-package=com.example.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**

4.http://localhost:8080/swagger-ui.html 查看接口文档

上一篇下一篇

猜你喜欢

热点阅读