zoukankan      html  css  js  c++  java
  • Spring 集成 Swagger UI

    <!-- Spring -->
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-web</artifactId>
    			<version>1.5.3.RELEASE</version>
    			<exclusions>
    				<exclusion>
    					<groupId>org.springframework.boot</groupId>
    					<artifactId>spring-boot-starter-tomcat</artifactId>
    				</exclusion>
    				<exclusion>
    					<groupId>org.springframework.boot</groupId>
    					<artifactId>spring-boot-starter-logging</artifactId>
    				</exclusion>
    			</exclusions>
    		</dependency>
    
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-log4j2</artifactId>
    			<version>1.5.3.RELEASE</version>
    		</dependency>
    
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-jetty</artifactId>
    			<version>1.5.3.RELEASE</version>
    			<exclusions>
    				<exclusion>
    					<groupId>com.fasterxml.jackson.core</groupId>
    					<artifactId>jackson-annotations</artifactId>
    				</exclusion>
    			</exclusions>
    		</dependency>
    
    		<dependency>
    			<groupId>io.springfox</groupId>
    			<artifactId>springfox-swagger2</artifactId>
    			<version>2.7.0</version>
    		</dependency>
    
    		<dependency>
    			<groupId>io.springfox</groupId>
    			<artifactId>springfox-swagger-ui</artifactId>
    			<version>2.7.0</version>
    		</dependency>
    
    		<dependency>
    			<groupId>io.swagger</groupId>
    			<artifactId>swagger-annotations</artifactId>
    			<version>1.5.13</version>
    		</dependency>
    
    import org.springframework.web.bind.annotation.PathVariable;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RestController;
    
    @RestController
    public class ExampleController {
    
    	@RequestMapping(value = "hello/{name}", method = RequestMethod.GET)
    	public String greeting(@PathVariable("name") String name) {
    		return "hello my friend : " + name;
    	}
    	
    }
    

      

     

    访问地址 xxxx:8080/v2/api-docs 可以查看json数据

     访问 xxxx:8080/swagger-ui.html  直接查看ui

    参考文档

    http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

    http://www.conglin-site.com/document/html/1494763157.html

    https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X#apiparam

  • 相关阅读:
    centos7编译安装php 遇到的问题
    linux中以.d结尾的目录
    webpack 的安装与使用
    nginx 设置反向代理
    常用git命令
    windows命令行模式打开目录
    scapy 中sniff指定的数据包并打印指定信息
    python scapy中sniffer的用法以及过滤器
    scapy构造数据包
    21天实战人工智能系列:人工智能产品经理最佳实践(1)
  • 原文地址:https://www.cnblogs.com/xuchenCN/p/6924131.html
Copyright © 2011-2022 走看看