swagger使用

2019-04-17  本文已影响0人  朱芮林

1.在pom.xml中添加相关依赖

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

2.在主类application中添加注释:@EnableSwagger2Doc

import com.spring4all.swagger.EnableSwagger2Doc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableSwagger2Doc
public class SpringBootWebsocketApplication {

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

}

3.在application.properties中添加相关代码

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=zrl
swagger.contact.url=https://www.jianshu.com/u/ce6045cb864d
swagger.contact.email=824772535@qq.com
swagger.base-package=com.springboot.websocket.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**

根据个人不同情况修改!

4.最后打开浏览器网址

http://localhost:8080/swagger-ui.html

上一篇下一篇

猜你喜欢

热点阅读