Swagger学习(一、入门)

 

 Swagger学习(一、入门)

 

 Swagger学习(一、入门)

 

简单 入门(效果)

Swagger学习(一、入门)

 

 Swagger学习(一、入门)

 

 SwaggerConfig.class

@Configuration   //变成配置文件
@EnableSwagger2  //开启swagger2
public class SwaggerConfig {
}

 pom.xml

<dependencies>
        <!--swagger-->
        <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>

        <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>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

 HelloController.class

@RestController
public class HelloController {
    @RequestMapping("/hello")
    public String hello(){
        return "hello swagger";
    }
}

 不要忘记Swagger的配置文件 SwaggerConfig.class就好了

相关文章:

  • 2021-12-10
  • 2021-12-10
  • 2021-12-26
猜你喜欢
  • 2021-06-28
  • 2021-09-21
  • 2022-12-23
  • 2022-03-06
  • 2021-11-05
  • 2021-12-06
  • 2021-07-13
相关资源
相似解决方案