Ver Fonte

添加web模块 swagger

chudk há 7 anos atrás
pai
commit
5ce1612b21

+ 14 - 0
pom.xml

@@ -38,11 +38,25 @@
             <artifactId>netty-all</artifactId>
             <version>4.1.15.Final</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>
 		</dependency>
+		<dependency>
+	        <groupId>io.springfox</groupId>
+	    	<artifactId>springfox-swagger2</artifactId>
+	    	    <version>2.2.2</version>
+		</dependency>
+		<dependency>
+	    	<groupId>io.springfox</groupId>
+	    	<artifactId>springfox-swagger-ui</artifactId>
+	    	    <version>2.2.2</version>
+		</dependency>
 	</dependencies>
 
 	<build>

+ 0 - 1
src/main/java/com/tidecloud/datacceptance/service/impl/DiscardServerHandler.java

@@ -18,7 +18,6 @@ import java.util.Map;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import com.tidecloud.dataacceptance.entity.Advice;

+ 40 - 0
src/main/java/com/tidecloud/datacceptance/swagger/SwaggerConfig.java

@@ -0,0 +1,40 @@
+package com.tidecloud.datacceptance.swagger;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+/**   
+ * @author: chudk 
+ * @date:   2017年9月28日 上午11:23:52   
+ */
+@Configuration
+@EnableSwagger2
+public class SwaggerConfig {
+    
+    @Bean
+    public Docket createRestApi(){
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.tidecloud.datacceptance.web"))
+                .paths(PathSelectors.any())
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("手表调节RESTful API")
+                .description("----------")
+                .termsOfServiceUrl("--------termOfServiceUrl-----------")
+                .contact("contact")
+                .build();
+    }
+}

+ 13 - 0
src/main/java/com/tidecloud/datacceptance/web/WatchController.java

@@ -0,0 +1,13 @@
+package com.tidecloud.datacceptance.web;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**   
+ * @author: chudk 
+ * @date:   2017年9月28日 上午11:14:50   
+ */
+@RestController
+public class WatchController {
+    
+    
+}