Skip to content

Commit

Permalink
fix(*) 新增-starter-dubbo模块
Browse files Browse the repository at this point in the history
支持dubbo2.x、dubbo3.x ,并结合zookeeper、nacos
  • Loading branch information
Zhengjiaao committed Jun 28, 2022
1 parent fef152a commit 30c0782
Show file tree
Hide file tree
Showing 44 changed files with 1,181 additions and 0 deletions.
Empty file added starter-dubbo/README.md
Empty file.
20 changes: 20 additions & 0 deletions starter-dubbo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zja</groupId>
<artifactId>spring-boot-starter-test-root</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>

<groupId>com.zja</groupId>
<artifactId>starter-dubbo</artifactId>
<packaging>pom</packaging>

<modules>
<module>starter-dubbo2x</module>
<module>starter-dubbo3x</module>
</modules>

</project>
Empty file.
54 changes: 54 additions & 0 deletions starter-dubbo/starter-dubbo2x/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zja</groupId>
<artifactId>starter-dubbo</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>

<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x</artifactId>
<packaging>pom</packaging>

<modules>
<module>starter-dubbo2x-api</module>
<module>starter-dubbo2x-na-consumer</module>
<module>starter-dubbo2x-na-provider</module>
</modules>

<properties>
<dubbo.version>2.7.15</dubbo.version>
<!--注意,需要是1.4.2 ,参考:dubbo-dependencies-bom中 nacos-client -->
<nacos.version>1.4.2</nacos.version>
</properties>

<dependencyManagement>
<dependencies>
<!--spring-boot-dependencies-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-dependencies.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Apache Dubbo -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-bom</artifactId>
<version>${dubbo.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
21 changes: 21 additions & 0 deletions starter-dubbo/starter-dubbo2x/starter-dubbo2x-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>

<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x-api</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @Company: 上海数慧系统技术有限公司
* @Department: 数据中心
* @Author: 郑家骜[ào]
* @Email: [email protected]
* @Date: 2022-06-27 13:55
* @Since:
*/
package com.zja.dubbo.api;

public interface DemoService {
String sayHello(String name);
}
43 changes: 43 additions & 0 deletions starter-dubbo/starter-dubbo2x/starter-dubbo2x-na-consumer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>

<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x-na-consumer</artifactId>
<packaging>jar</packaging>

<dependencies>
<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>

<!-- Dubbo Spring Boot Starter -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @Company: 上海数慧系统技术有限公司
* @Department: 数据中心
* @Author: 郑家骜[ào]
* @Email: [email protected]
* @Date: 2022-06-28 13:13
* @Since:
*/
package com.zja.dubbo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Dubbo2xNAConsumerApplication {

public static void main(String[] args) {
SpringApplication.run(Dubbo2xNAConsumerApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @Company: 上海数慧系统技术有限公司
* @Department: 数据中心
* @Author: 郑家骜[ào]
* @Email: [email protected]
* @Date: 2022-06-27 14:00
* @Since:
*/
package com.zja.dubbo.consumer;

import com.zja.dubbo.api.DemoService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dubbo")
public class DemoController {

@DubboReference(version = "1.0.0", url = "dubbo://127.0.0.1:12345")
DemoService demoService;

/**
* http://localhost:8081/consumer/dubbo/sayHello
*/
@GetMapping("/sayHello")
public ResponseEntity queryById() {
return ResponseEntity.ok(demoService.sayHello("李四"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
server:
port: 8081
servlet:
context-path: /consumer
spring:
application:
name: dubbo-auto-configuration-consumer

44 changes: 44 additions & 0 deletions starter-dubbo/starter-dubbo2x/starter-dubbo2x-na-provider/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>

<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x-na-provider</artifactId>
<packaging>jar</packaging>

<dependencies>
<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>

<!-- Dubbo Spring Boot Starter -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>

<dependency>
<groupId>com.zja</groupId>
<artifactId>starter-dubbo2x-api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* @Company: 上海数慧系统技术有限公司
* @Department: 数据中心
* @Author: 郑家骜[ào]
* @Email: [email protected]
* @Date: 2022-06-28 13:13
* @Since:
*/
package com.zja.dubbo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Dubbo2xNAProviderApplication {

public static void main(String[] args) {
SpringApplication.run(Dubbo2xNAProviderApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @Company: 上海数慧系统技术有限公司
* @Department: 数据中心
* @Author: 郑家骜[ào]
* @Email: [email protected]
* @Date: 2022-06-27 13:56
* @Since:
*/
package com.zja.dubbo.provider;

import com.zja.dubbo.api.DemoService;
import org.apache.dubbo.config.annotation.DubboService;

@DubboService(version = "1.0.0")
public class DemoServiceImpl implements DemoService {
@Override
public String sayHello(String name) {
return name + " 你好,您调用 DUBBO RPC 接口成功!";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
server:
port: 8082
servlet:
context-path: /provider
spring:
application:
name: dubbo-auto-configuration-provider

dubbo:
scan:
base-packages: com.zja.dubbo.provider
protocol:
name: dubbo
port: 12345
registry:
address: N/A # 无需注册到服务注册中心
Empty file.
58 changes: 58 additions & 0 deletions starter-dubbo/starter-dubbo3x/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.zja</groupId>
<artifactId>starter-dubbo</artifactId>
<version>2.0-SNAPSHOT</version>
</parent>

<groupId>com.zja</groupId>
<artifactId>starter-dubbo3x</artifactId>
<packaging>pom</packaging>

<modules>
<module>starter-dubbo3x-api</module>
<module>starter-dubbo3x-na-consumer</module>
<module>starter-dubbo3x-na-provider</module>
<module>starter-dubbo3x-nacos-consumer</module>
<module>starter-dubbo3x-nacos-provider</module>
<module>starter-dubbo3x-zookeeper-consumer</module>
<module>starter-dubbo3x-zookeeper-provider</module>
</modules>

<properties>
<dubbo.version>3.0.9</dubbo.version>
<!--注意,需要大于2.1.0-->
<nacos.version>2.1.0</nacos.version>
</properties>

<dependencyManagement>
<dependencies>
<!--spring-boot-dependencies-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot-dependencies.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- Apache Dubbo -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-bom</artifactId>
<version>${dubbo.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Loading

0 comments on commit 30c0782

Please sign in to comment.