In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to configure Swagger2 login password for Springboot". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Swagger
Swagger is the most widely used tool ecosystem for developing API using the OpenAPI specification (OAS). Swagger consists of open source and professional tools that meet almost all needs and use cases.
1. Configure Swagger
Add dependency
/ / web depends on org.springframework.boot spring-boot-starter-web//swagger depends on io.springfox springfox-swagger2 2.9.2 io.springfox springfox-swagger-ui 2.9.2
Add configuration class
@ Configuration@EnableSwagger2public class SwaggerConfig {@ Bean public Docket createRestApi () {return new Docket (DocumentationType.SWAGGER_2) .groupName (") .apiInfo (apiInfo ()) .select () .ap is (RequestHandlerSelectors.basePackage (" package name ") .build () } public ApiInfo apiInfo () {return new ApiInfoBuilder () .title ("interface") .description ("interface description") .version ("1.0") .build ();}}
Use
/ / Control layer @ Api (tags = "basic module") @ RestController@RequestMapping ("/ base") public class BaseController {@ ApiOperation (value = "query") @ RequestMapping (value = "/ findList", method = RequestMethod.POST) public RestResponse findList (@ RequestBody Param param) {return RestResponse.ok ();}}
Access address
Localhost:8080/swagger-ui.html
Exposing the interface document to the public network will cause some security problems. At this time, we need to configure the login password for the Swagger document.
Configure Swagger login password
Add dependency
Com.github.xiaoymin swagger-bootstrap-ui 1.9.3
Update configuration class
@ Configuration@EnableSwagger2@EnableSwaggerBootstrapUI / / add comment public class SwaggerConfig {}
Add startup class comments
@ EnableSwagger2
Configure the yaml file
Swagger: basic: enable: true / / enable username: username password: password "how to configure Swagger2 login password for Springboot". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.