swagger生態(tài)圖
image
swagger UI 使用方法
- 在pom.xml中引入依賴
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.8.0.RELEASE</version>
</dependency>
- 在應(yīng)用主類中增加@EnableSwagger2Doc注解
@SpringBootApplication
@EnableSwagger2Doc
public class Springboot2Swagger2Application {
public static void main(String[] args) {
SpringApplication.run(Springboot2Swagger2Application.class, args);
}
}
默認(rèn)情況下就能產(chǎn)生所有當(dāng)前SpringMVC加載的請(qǐng)求映射文檔
訪問地址:http://localhost:8080/swagger-ui.html
- 參數(shù)配置示例
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=mqXu
swagger.contact.url=http://www.reibang.com/u/822585e5c69a
swagger.contact.email=moqi1977@gmail.com
swagger.base-package=com.springboot.mybatis.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**
swagger UI整體效果
image