ImportOrg.springframework.context.annotation.Bean;Importorg.springframework.context.annotation.Configuration;ImportSpringfox.documentation.builders.ApiInfoBuilder;Importspringfox.documentation.builders.PathSelectors;ImportSpringfox.documentation.service.ApiInfo;Importspringfox.documentation.service.Contact;ImportSpringfox.documentation.spi.DocumentationType;ImportSpringfox.documentation.spring.web.plugins.Docket;ImportSpringfox.documentation.swagger2.annotations.EnableSwagger2, @Configuration @enableswagger2 Public classSwagger2config {@Bean PublicDocket Restapiforsensors () {return NewDocket (documentationtype.swagger_2). Apiinfo (Apiinfo ()). GroupName ("Sensors data"). Forcodegeneration (true). Select ()//. APIs (Requesthandlerselectors.withclassannotation (api.class))//. APIs (Requesthandlerselectors.withmethodannotation (apioperation.class)). Paths (Pathselectors.ant ("/api/sensors/data/**") . Build (). Usedefaultresponsemessages (false); } Privateapiinfo Apiinfo () {return NewApiinfobuilder (). Title ("Times full springboot Swagger2 RESTful API"). Contact (NewContact ("Hjzgg", "", "[email protected]"). Description ("Static Token=xxx"). Version ("2.0"). build (); }}
Operating effect:
Resources:
Spring-boot Integrated Springfox-swagger2
Spring-antpathmatcher
Spring-boot Integrated Springfox-swagger2