java ssm api接口_SSM接口可视化

1 工具

2 配置

2.1 pom.xml

io.springfox

springfox-swagger2

2.6.1

io.springfox

springfox-swagger-ui

2.6.1

2.2 接口配置类

ApplicationShow.java

package com.document;

import org.springframework.context.annotation.Bean;

import org.springframework.context.annotation.ComponentScan;

import org.springframework.context.annotation.Configuration;

// import org.springframework.test.context.web.WebAppConfiguration;

import org.springframework.web.servlet.config.annotation.EnableWebMvc;

import springfox.documentation.builders.RequestHandlerSelectors;

import springfox.documentation.builders.ApiInfoBuilder;

import springfox.documentation.spi.DocumentationType;

import springfox.documentation.spring.web.plugins.Docket;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

import springfox.documentation.service.ApiInfo;

@Configuration

@EnableSwagger2

@EnableWebMvc

@ComponentScan(basePackages="com.controller.bigdata")

// public class ApplicationShow extends WebMvcConfigurationSupport{

public class ApplicationShow{

@Bean

public Docket api(){

return new Docket(DocumentationType.SWAGGER_2)

.select()

.apis(RequestHandlerSelectors.any())

.build()

.apiInfo(apiInfo());

}

private ApiInfo apiInfo(){

return new ApiInfoBuilder()

.title("接口文档")

.description("接口可视化")

.version("1.0.0")

.termsOfServiceUrl("")

.license("")

.licenseUrl("")

.build();

}

}

2.3 静态文件

路径:新建文件夹/api-document/version2

/webapp/api-document/version2

github的dist文件夹中的全部文件拷贝至version2文件夹下

映射配置

2.4 url配置

/webapp/api-document/version2/index.html

url:http://localhost:8080/{artifactId}/v2/api-docs

2.5 controller配置

package com.controller.bigdata;

import java.util.Map;

import ***.po.className;

import ***.service.classNameService;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.annotation.Qualifier;

import org.springframework.http.ResponseEntity;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.ResponseBody;

import io.swagger.annotations.Api;

import io.swagger.annotations.ApiOperation;

@Controller

@RequestMapping("/api")

@Api(value="/api", tags="功能测试", description="数据搜索性能分析")

public class TestController{

@Autowired

private DeviceStatusService deviceStatusService;

@RequestMapping(value="/map-return", method=RequestMethod.POST)

@ResponseBody

@ApiOperation(value="测试接口连接")

public Map mapReturn(@RequestBody Map infos){

return infos;

}

}

2.6 中文

/webapp/api-document/version2/index.html

3 接口界面

29cab2b3885a86dc07d8a118525791ac.png

图3.1 接口界面

标签:springframework,SSM,api,可视化,接口,org,import,springfox,annotation

来源: https://blog.csdn.net/Xin_101/article/details/102769777

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值