SpringBoot 集成 Swagger 最小配置
2021-06-15 本文已影响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 {
}