在springboot项目中无侵入的添加swaggerui


在springboot项目中无侵入的添加swaggerui

1、在pom.xml中添加swaggerui相关依赖

        <dependency>
            <groupId>io.springfoxgroupId>
            <artifactId>springfox-swagger2artifactId>
            <version>2.5.0version>
        dependency>
        <dependency>
            <groupId>io.springfoxgroupId>
            <artifactId>springfox-swagger-uiartifactId>
            <version>2.5.0version>
        dependency>

2、在项目的config文件夹下添加swaggerconfig类

package com.demo.config;

import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
}

3、添加一个controller服务类

4、运行后在浏览器输入:http://localhost:8002/swagger-ui.html