<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                案例代碼:https://gitee.com/flymini/codes01/tree/master/springboot_/com-learn-boot12 **** 后端生成文檔給前端程序員參考,方便前端程序員開發。我們可以借助 Swagger2 工具來生成文檔。 <br/> 使用步驟如下: **1. 引入swagger2依賴** ```xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> </dependencies> ``` **2. 注冊Swagger2到IoC容器** ```java @Configuration @EnableSwagger2 public class Swagger2Config { @Bean public Docket docket() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() //只能對controller層生成文檔 .apis(RequestHandlerSelectors.basePackage("com.learn.boot12.controller")) .paths(PathSelectors.any()).build(); } private ApiInfo apiInfo() { return new ApiInfoBuilder() //文檔標題 .title("com-learn-boot12項目文檔") //作者, 地址, 郵箱 .contact(new Contact("Zhangsan", "www.baidu.com", "123@163.com")) .version("1.0") .description("com-learn-boot12項目文檔").build(); } } ``` **3. 在controller層調用Swagger2相關注解說明** ```java @Controller @Api(tags = "有關用戶的所有操作!") //UserController類的文檔說明 public class UserController { @ApiOperation(value = "用戶登錄功能!", notes = "需要前端傳遞賬號和密碼!") //該方法的文檔說明 @ApiImplicitParams({ //該方法的參數說明 @ApiImplicitParam(name = "userName", value = "賬戶名", dataType = "String", example = "zhangsan"), @ApiImplicitParam(name = "password", value = "密碼", dataType = "String", example = "123456") }) @RequestMapping(value = "/loginManager", method = RequestMethod.POST) public String login(@RequestParam("userName") String userName , @RequestParam("password") String password , HttpServletRequest request) { return "/main"; } } ``` **4. 啟動SpringBoot項目** 訪問 http://localhost:8080/swagger-ui.html 即可看到文檔。 ![](https://img.kancloud.cn/c8/3f/c83fa3df1469a925f068d728c334f5dd_780x372.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看