You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 3.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # spring-boot-demo-dubbo-consumer
  2. > 此 module 主要是服务调用方的示例
  3. ## pom.xml
  4. ```xml
  5. <?xml version="1.0" encoding="UTF-8"?>
  6. <project xmlns="http://maven.apache.org/POM/4.0.0"
  7. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  8. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  9. <parent>
  10. <artifactId>spring-boot-demo-dubbo</artifactId>
  11. <groupId>com.xkcoding</groupId>
  12. <version>1.0.0-SNAPSHOT</version>
  13. </parent>
  14. <modelVersion>4.0.0</modelVersion>
  15. <artifactId>spring-boot-demo-dubbo-consumer</artifactId>
  16. <properties>
  17. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  18. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  19. <java.version>1.8</java.version>
  20. </properties>
  21. <dependencies>
  22. <dependency>
  23. <groupId>org.springframework.boot</groupId>
  24. <artifactId>spring-boot-starter-web</artifactId>
  25. </dependency>
  26. <dependency>
  27. <groupId>com.alibaba.spring.boot</groupId>
  28. <artifactId>dubbo-spring-boot-starter</artifactId>
  29. <version>${dubbo.starter.version}</version>
  30. </dependency>
  31. <dependency>
  32. <groupId>${project.groupId}</groupId>
  33. <artifactId>spring-boot-demo-dubbo-common</artifactId>
  34. <version>${project.version}</version>
  35. </dependency>
  36. <dependency>
  37. <groupId>com.101tec</groupId>
  38. <artifactId>zkclient</artifactId>
  39. <version>${zkclient.version}</version>
  40. </dependency>
  41. <dependency>
  42. <groupId>org.projectlombok</groupId>
  43. <artifactId>lombok</artifactId>
  44. <optional>true</optional>
  45. </dependency>
  46. <dependency>
  47. <groupId>org.springframework.boot</groupId>
  48. <artifactId>spring-boot-starter-test</artifactId>
  49. <scope>test</scope>
  50. </dependency>
  51. </dependencies>
  52. <build>
  53. <finalName>spring-boot-demo-dubbo-consumer</finalName>
  54. </build>
  55. </project>
  56. ```
  57. ## application.yml
  58. ```yaml
  59. server:
  60. port: 8080
  61. servlet:
  62. context-path: /demo
  63. spring:
  64. dubbo:
  65. application:
  66. name: spring-boot-demo-dubbo-consumer
  67. registry: zookeeper://127.0.0.1:2181
  68. ```
  69. ## SpringBootDemoDubboConsumerApplication.java
  70. ```java
  71. /**
  72. * <p>
  73. * 启动器
  74. * </p>
  75. *
  76. * @author yangkai.shen
  77. * @date Created in 2018-12-25 16:49
  78. */
  79. @SpringBootApplication
  80. @EnableDubboConfiguration
  81. public class SpringBootDemoDubboConsumerApplication {
  82. public static void main(String[] args) {
  83. SpringApplication.run(SpringBootDemoDubboConsumerApplication.class, args);
  84. }
  85. }
  86. ```
  87. ## HelloController.java
  88. ```java
  89. /**
  90. * <p>
  91. * Hello服务API
  92. * </p>
  93. *
  94. * @author yangkai.shen
  95. * @date Created in 2018-12-25 17:22
  96. */
  97. @RestController
  98. @Slf4j
  99. public class HelloController {
  100. @Reference
  101. private HelloService helloService;
  102. @GetMapping("/sayHello")
  103. public String sayHello(@RequestParam(defaultValue = "xkcoding") String name) {
  104. log.info("i'm ready to call someone......");
  105. return helloService.sayHello(name);
  106. }
  107. }
  108. ```

一个用来深度学习并实战 spring boot 的项目,目前总共包含 66 个集成demo,已经完成 55 个。