mirror of
https://github.com/Estom/notes.git
synced 2026-02-04 02:53:57 +08:00
39 lines
1010 B
Markdown
39 lines
1010 B
Markdown
## swagger2使用
|
||
|
||
### pom.xml添加依赖
|
||
|
||
```
|
||
<dependency>
|
||
<groupId>com.spring4all</groupId>
|
||
<artifactId>swagger-spring-boot-starter</artifactId>
|
||
<version>1.9.0.RELEASE</version>
|
||
</dependency>
|
||
```
|
||
|
||
### 应用主类中添加@EnableSwagger2Doc注解
|
||
|
||
```
|
||
@EnableSwagger2Doc
|
||
@SpringBootApplication
|
||
public class Chapter22Application {
|
||
|
||
public static void main(String[] args) {
|
||
SpringApplication.run(Chapter22Application.class, args);
|
||
}
|
||
|
||
}
|
||
```
|
||
|
||
### application.properties中配置文档相关内容,比如
|
||
|
||
swagger.title=spring-boot-starter-swagger
|
||
swagger.description=Starter for swagger 2.x
|
||
swagger.version=1.4.0.RELEASE
|
||
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=didi
|
||
swagger.contact.url=http://blog.didispace.com
|
||
swagger.contact.email=dyc87112@qq.com
|
||
swagger.base-package=com.didispace
|
||
swagger.base-path=/** |