In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces how to use the swagger of the Springboot project interface. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
The step1:pom file introduces the swagger plug-in
Io.springfox springfox-swagger2 2.9.2 io.springfox springfox-swagger-ui 2.9.2 org.springframework.boot spring-boot-starter-web
Step2: adding SwaggerConfig.java
Package com.ggkt.crm.admin.config;import org.springframework.beans.factory.annotation.Value;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import springfox.documentation.builders.ApiInfoBuilder;import springfox.documentation.builders.PathSelectors;import springfox.documentation.builders.RequestHandlerSelectors;import springfox.documentation.service.ApiInfo;import springfox.documentation.spi.DocumentationType;import springfox.documentation.spring.web.plugins.Docket;import springfox.documentation.swagger2.annotations.EnableSwagger2 / * Title: Swagger * Description: interface testing (available or not) * @ author ggkt * * / @ Configuration@EnableSwagger2public class SwaggerConfig {@ Value (value = "${swagger.enabled}") private Boolean swaggerEnabled @ Bean public Docket createAllotManageApi () {return new Docket (DocumentationType.SWAGGER_2) .apiInfo (apiInfo ()) .groupName ("assignment Management") / / whether .enable (swaggerEnabled) .apis (RequestHandlerSelectors. BasePackage ("com.ggkt.crm.admin.allotManage.dataType.controller")) / / specify the path processing PathSelectors.any () represents all paths. Paths (PathSelectors.any ()). Build (). PathMapping ("/") } @ Bean public Docket createMarketManageApi () {return new Docket (DocumentationType.SWAGGER_2) .apiInfo (apiInfo ()) .groupName ("Marketing Management") / / whether .enable (swaggerEnabled) .select () / / scanning path package .apis ( RequestHandlerSelectors.basePackage ("com.ggkt.crm.admin.marketManage")) / / specify the path processing PathSelectors.any () represents all paths. Paths (PathSelectors.any ()). Build (). PathMapping ("/") } @ Bean public Docket createBaseManageApi () {return new Docket (DocumentationType.SWAGGER_2) .apiInfo (apiInfo ()) .groupName ("basic configuration Management") / / whether .enable (swaggerEnabled) .select () / / scanned path package .apis (RequestHandlerSelectors.basePackage ( "com.ggkt.crm.admin.baseManage")) / / specify the path processing PathSelectors.any () represents all paths. Paths (PathSelectors.any ()). Build (). PathMapping ("/") } private ApiInfo apiInfo () {return new ApiInfoBuilder () .title ("interface document") .description ("API") .version ("1.0.0") .build ();}}
Step3:domain class annotation mode
The way step4:Controller classes are annotated
Step5:application.yml configuration
6. Interface access
Http://localhost:9099/admin/swagger-ui.html
This is the end of how to use the swagger of the Springboot project interface. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.