美文网首页
swagger使用

swagger使用

作者: 朱芮林 | 来源:发表于2019-04-17 13:28 被阅读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

    相关文章

      网友评论

          本文标题:swagger使用

          本文链接:https://www.haomeiwen.com/subject/lgagwqtx.html