What is swagger?
Swagger is a background staff specialized testing a simple tool, especially suitable for the front-end separation of the project, before we have been using the postman, but this is a bit complicated, the path needs their own, and swagger is directly used, then we directly on the code said swagger, Literary talent is not good to forgive!
1. First two jar packages required
<dependency><groupid>io.springfox</groupid><artifactid>springfox-swagger2</ Artifactid><version>2.6.1</version></dependency><dependency><groupid> io.springfox</groupid><artifactid>springfox-swagger-ui</artifactid><version>2.6.1</ Version></dependency>
2. Configuring the Swagger Core class
@Configurationpublic class Swagger2 {@Beanpublic Docket Createrestapi () {return new docket (documentationtype.swagger_2 ). Apiinfo (Apiinfo ()). Select (). APIs (Requesthandlerselectors.basepackage (" Com.pcitc.scl.business.productoil.service.controller "))//own package name. Paths (Pathselectors.any ()). build ();} Private Apiinfo Apiinfo () {return new Apiinfobuilder (). Title ("Springboot build API documentation using swagger"). Description (" Simple and elegant restfun style, Http://blog.csdn.net/saytime "). Termsofserviceurl (" Http://blog.csdn.net/saytime "). Version (" 1.0 ") . build ();}}
3.springapppplication.java configuration in the Springboot core class
The main is to add annotations on the class @enableswagger2
Finally directly
Http://localhost:8080/swagger-ui.html
You can see your project, if the project name does not come up or the project does not start, please follow my other article
Swagger+springboot Integration Integration (three-step view)