美文网首页
SpringBoot 集成 Swagger 最小配置

SpringBoot 集成 Swagger 最小配置

作者: 李威威 | 来源:发表于2021-06-15 11:21 被阅读0次

    引入包

    plugins {
        id 'java'
    }
    
    group 'org.example'
    version '1.0-SNAPSHOT'
    
    allprojects {
        repositories {
            maven {
                url 'https://maven.aliyun.com/repository/public/'
            }
            mavenLocal()
            mavenCentral()
        }
    }
    
    dependencies {
        implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.5.1'
        implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'
    }
    
    test {
        useJUnitPlatform()
    }
    

    启动类

    package com.sunfa8.demo;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.web.bind.annotation.RestController;
    
    @SpringBootApplication
    @RestController
    public class DemoApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    }
    

    配置

    package com.sunfa8.demo;
    
    import org.springframework.context.annotation.Configuration;
    import springfox.documentation.swagger2.annotations.EnableSwagger2;
    
    @Configuration
    @EnableSwagger2
    public class SwaggerConfig {
    }
    

    相关文章

      网友评论

          本文标题:SpringBoot 集成 Swagger 最小配置

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