正在显示
7 个修改的文件
包含
228 行增加
和
0 行删除
| @@ -27,5 +27,10 @@ | @@ -27,5 +27,10 @@ | ||
| 27 | <groupId>io.springfox</groupId> | 27 | <groupId>io.springfox</groupId> |
| 28 | <artifactId>springfox-swagger-ui</artifactId> | 28 | <artifactId>springfox-swagger-ui</artifactId> |
| 29 | </dependency> | 29 | </dependency> |
| 30 | + | ||
| 31 | + <dependency> | ||
| 32 | + <groupId>com.github.sgroschupf</groupId> | ||
| 33 | + <artifactId>zkclient</artifactId> | ||
| 34 | + </dependency> | ||
| 30 | </dependencies> | 35 | </dependencies> |
| 31 | </project> | 36 | </project> |
netty-action-zk/pom.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| 3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 4 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 5 | + <parent> | ||
| 6 | + <artifactId>netty-action</artifactId> | ||
| 7 | + <groupId>com.crossoverjie.netty</groupId> | ||
| 8 | + <version>1.0.0-SNAPSHOT</version> | ||
| 9 | + </parent> | ||
| 10 | + <modelVersion>4.0.0</modelVersion> | ||
| 11 | + | ||
| 12 | + <artifactId>netty-action-zk</artifactId> | ||
| 13 | + | ||
| 14 | + | ||
| 15 | + <dependencies> | ||
| 16 | + <dependency> | ||
| 17 | + <groupId>com.crossoverjie.netty</groupId> | ||
| 18 | + <artifactId>netty-action-common</artifactId> | ||
| 19 | + </dependency> | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + <dependency> | ||
| 23 | + <groupId>io.springfox</groupId> | ||
| 24 | + <artifactId>springfox-swagger2</artifactId> | ||
| 25 | + <scope>compile</scope> | ||
| 26 | + </dependency> | ||
| 27 | + <dependency> | ||
| 28 | + <groupId>io.springfox</groupId> | ||
| 29 | + <artifactId>springfox-swagger-ui</artifactId> | ||
| 30 | + </dependency> | ||
| 31 | + | ||
| 32 | + <dependency> | ||
| 33 | + <groupId>org.springframework.boot</groupId> | ||
| 34 | + <artifactId>spring-boot-starter-web</artifactId> | ||
| 35 | + </dependency> | ||
| 36 | + <dependency> | ||
| 37 | + <groupId>org.springframework.boot</groupId> | ||
| 38 | + <artifactId>spring-boot-starter-test</artifactId> | ||
| 39 | + <scope>test</scope> | ||
| 40 | + </dependency> | ||
| 41 | + | ||
| 42 | + <dependency> | ||
| 43 | + <groupId>org.springframework.boot</groupId> | ||
| 44 | + <artifactId>spring-boot-configuration-processor</artifactId> | ||
| 45 | + <optional>true</optional> | ||
| 46 | + </dependency> | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + <dependency> | ||
| 50 | + <groupId>org.springframework.boot</groupId> | ||
| 51 | + <artifactId>spring-boot-starter-actuator</artifactId> | ||
| 52 | + </dependency> | ||
| 53 | + | ||
| 54 | + <dependency> | ||
| 55 | + <groupId>de.codecentric</groupId> | ||
| 56 | + <artifactId>spring-boot-admin-starter-client</artifactId> | ||
| 57 | + </dependency> | ||
| 58 | + | ||
| 59 | + <dependency> | ||
| 60 | + <groupId>ch.qos.logback</groupId> | ||
| 61 | + <artifactId>logback-classic</artifactId> | ||
| 62 | + </dependency> | ||
| 63 | + | ||
| 64 | + <dependency> | ||
| 65 | + <groupId>junit</groupId> | ||
| 66 | + <artifactId>junit</artifactId> | ||
| 67 | + </dependency> | ||
| 68 | + | ||
| 69 | + <dependency> | ||
| 70 | + <groupId>com.alibaba</groupId> | ||
| 71 | + <artifactId>fastjson</artifactId> | ||
| 72 | + </dependency> | ||
| 73 | + | ||
| 74 | + <dependency> | ||
| 75 | + <groupId>com.google.guava</groupId> | ||
| 76 | + <artifactId>guava</artifactId> | ||
| 77 | + </dependency> | ||
| 78 | + </dependencies> | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + <build> | ||
| 82 | + <plugins> | ||
| 83 | + <!-- spring-boot-maven-plugin (提供了直接运行项目的插件:如果是通过parent方式继承spring-boot-starter-parent则不用此插件) --> | ||
| 84 | + <plugin> | ||
| 85 | + <groupId>org.springframework.boot</groupId> | ||
| 86 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
| 87 | + <executions> | ||
| 88 | + <execution> | ||
| 89 | + <goals> | ||
| 90 | + <goal>repackage</goal> | ||
| 91 | + </goals> | ||
| 92 | + </execution> | ||
| 93 | + </executions> | ||
| 94 | + </plugin> | ||
| 95 | + </plugins> | ||
| 96 | + </build> | ||
| 97 | + | ||
| 98 | +</project> |
| 1 | +package com.crossoverjie.netty.action.zk; | ||
| 2 | + | ||
| 3 | +import org.slf4j.Logger; | ||
| 4 | +import org.slf4j.LoggerFactory; | ||
| 5 | +import org.springframework.boot.CommandLineRunner; | ||
| 6 | +import org.springframework.boot.SpringApplication; | ||
| 7 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * @author crossoverJie | ||
| 11 | + */ | ||
| 12 | +@SpringBootApplication | ||
| 13 | +public class Application implements CommandLineRunner{ | ||
| 14 | + | ||
| 15 | + private final static Logger LOGGER = LoggerFactory.getLogger(Application.class); | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + public static void main(String[] args) { | ||
| 20 | + SpringApplication.run(Application.class, args); | ||
| 21 | + LOGGER.info("启动应用成功"); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + @Override | ||
| 25 | + public void run(String... args) throws Exception { | ||
| 26 | + } | ||
| 27 | +} |
| 1 | +package com.crossoverjie.netty.action.zk.config; | ||
| 2 | + | ||
| 3 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
| 4 | +import org.springframework.context.annotation.Bean; | ||
| 5 | +import org.springframework.context.annotation.Configuration; | ||
| 6 | +import springfox.documentation.builders.ApiInfoBuilder; | ||
| 7 | +import springfox.documentation.builders.PathSelectors; | ||
| 8 | +import springfox.documentation.builders.RequestHandlerSelectors; | ||
| 9 | +import springfox.documentation.service.ApiInfo; | ||
| 10 | +import springfox.documentation.spi.DocumentationType; | ||
| 11 | +import springfox.documentation.spring.web.plugins.Docket; | ||
| 12 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
| 13 | + | ||
| 14 | + | ||
| 15 | +@Configuration | ||
| 16 | +@EnableSwagger2 | ||
| 17 | +/** 是否打开swagger **/ | ||
| 18 | +@ConditionalOnExpression("'${swagger.enable}' == 'true'") | ||
| 19 | +public class SwaggerConfig { | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + @Bean | ||
| 23 | + public Docket createRestApi() { | ||
| 24 | + return new Docket(DocumentationType.SWAGGER_2) | ||
| 25 | + .apiInfo(apiInfo()) | ||
| 26 | + .select() | ||
| 27 | + .apis(RequestHandlerSelectors.basePackage("com.crossoverjie.netty.action.zk.controller")) | ||
| 28 | + .paths(PathSelectors.any()) | ||
| 29 | + .build(); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + private ApiInfo apiInfo() { | ||
| 33 | + return new ApiInfoBuilder() | ||
| 34 | + .title("netty-action-zk api") | ||
| 35 | + .description("netty-action-zk api") | ||
| 36 | + .termsOfServiceUrl("https://crossoverJie.top") | ||
| 37 | + .contact("crossoverJie") | ||
| 38 | + .version("1.0.0") | ||
| 39 | + .build(); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | +} |
netty-action-zk/src/main/java/com/crossoverjie/netty/action/zk/controller/IndexController.java
0 → 100644
| 1 | +package com.crossoverjie.netty.action.zk.controller; | ||
| 2 | + | ||
| 3 | +import com.crossoverjie.netty.action.common.enums.StatusEnum; | ||
| 4 | +import com.crossoverjie.netty.action.common.res.BaseResponse; | ||
| 5 | +import com.crossoverjie.netty.action.common.res.NULLBody; | ||
| 6 | +import io.swagger.annotations.ApiOperation; | ||
| 7 | +import org.springframework.stereotype.Controller; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 9 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 10 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Function: | ||
| 14 | + * | ||
| 15 | + * @author crossoverJie | ||
| 16 | + * Date: 22/05/2018 14:46 | ||
| 17 | + * @since JDK 1.8 | ||
| 18 | + */ | ||
| 19 | +@Controller | ||
| 20 | +@RequestMapping("/") | ||
| 21 | +public class IndexController { | ||
| 22 | + | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 获取所有路由节点 | ||
| 26 | + * @return | ||
| 27 | + */ | ||
| 28 | + @ApiOperation("获取所有路由节点") | ||
| 29 | + @RequestMapping(value = "getRoute",method = RequestMethod.POST) | ||
| 30 | + @ResponseBody() | ||
| 31 | + public BaseResponse<NULLBody> getRoute(){ | ||
| 32 | + BaseResponse<NULLBody> res = new BaseResponse(); | ||
| 33 | + res.setCode(StatusEnum.SUCCESS.getCode()) ; | ||
| 34 | + res.setMessage("127.0.0.1:8080") ; | ||
| 35 | + return res ; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + | ||
| 39 | +} |
| @@ -31,12 +31,20 @@ | @@ -31,12 +31,20 @@ | ||
| 31 | <module>netty-action-heartbeat-client</module> | 31 | <module>netty-action-heartbeat-client</module> |
| 32 | <module>netty-action-common</module> | 32 | <module>netty-action-common</module> |
| 33 | <module>springboot-admin</module> | 33 | <module>springboot-admin</module> |
| 34 | + <module>netty-action-zk</module> | ||
| 34 | </modules> | 35 | </modules> |
| 35 | 36 | ||
| 36 | 37 | ||
| 37 | <dependencyManagement> | 38 | <dependencyManagement> |
| 38 | <dependencies> | 39 | <dependencies> |
| 39 | 40 | ||
| 41 | + | ||
| 42 | + <dependency> | ||
| 43 | + <groupId>com.github.sgroschupf</groupId> | ||
| 44 | + <artifactId>zkclient</artifactId> | ||
| 45 | + <version>0.1</version> | ||
| 46 | + </dependency> | ||
| 47 | + | ||
| 40 | <dependency> | 48 | <dependency> |
| 41 | <groupId>com.crossoverjie.netty</groupId> | 49 | <groupId>com.crossoverjie.netty</groupId> |
| 42 | <artifactId>netty-action-common</artifactId> | 50 | <artifactId>netty-action-common</artifactId> |
-
请 注册 或 登录 后发表评论