增加 SOFARPC 入门

This commit is contained in:
YunaiV
2020-06-10 20:46:23 +08:00
parent 2a2720e6fe
commit f7fe0a245d
38 changed files with 776 additions and 13 deletions

View File

@@ -0,0 +1,16 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>lab-62-sofarpc-xml-demo</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-62-sofarpc-annotations-demo-user-rpc-service-api</artifactId>
</project>

View File

@@ -0,0 +1,27 @@
package cn.iocoder.springboot.lab62.rpc.api;
import cn.iocoder.springboot.lab62.rpc.dto.UserAddDTO;
import cn.iocoder.springboot.lab62.rpc.dto.UserDTO;
/**
* 用户服务 RPC Service 接口
*/
public interface UserRpcService {
/**
* 根据指定用户编号,获得用户信息
*
* @param id 用户编号
* @return 用户信息
*/
UserDTO get(Integer id);
/**
* 添加新用户,返回新添加的用户编号
*
* @param addDTO 添加的用户信息
* @return 用户编号
*/
Integer add(UserAddDTO addDTO);
}

View File

@@ -0,0 +1,37 @@
package cn.iocoder.springboot.lab62.rpc.dto;
import java.io.Serializable;
/**
* 用户添加 DTO
*/
public class UserAddDTO implements Serializable {
/**
* 昵称
*/
private String name;
/**
* 性别
*/
private Integer gender;
public String getName() {
return name;
}
public UserAddDTO setName(String name) {
this.name = name;
return this;
}
public Integer getGender() {
return gender;
}
public UserAddDTO setGender(Integer gender) {
this.gender = gender;
return this;
}
}

View File

@@ -0,0 +1,49 @@
package cn.iocoder.springboot.lab62.rpc.dto;
import java.io.Serializable;
/**
* 用户信息 DTO
*/
public class UserDTO implements Serializable {
/**
* 用户编号
*/
private Integer id;
/**
* 昵称
*/
private String name;
/**
* 性别
*/
private Integer gender;
public Integer getId() {
return id;
}
public UserDTO setId(Integer id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public UserDTO setName(String name) {
this.name = name;
return this;
}
public Integer getGender() {
return gender;
}
public UserDTO setGender(Integer gender) {
this.gender = gender;
return this;
}
}

View File

@@ -0,0 +1,45 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<!-- <artifactId>lab-62-sofarpc-xml-demo</artifactId>-->
<!-- <groupId>cn.iocoder.springboot.labs</groupId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<groupId>com.alipay.sofa</groupId>
<artifactId>sofaboot-dependencies</artifactId>
<version>3.3.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-62-sofarpc-annotations-demo-user-rpc-service-consumer</artifactId>
<dependencies>
<!-- 引入定义的 SOFARPC API 接口 -->
<dependency>
<groupId>cn.iocoder.springboot.labs</groupId>
<artifactId>lab-62-sofarpc-annotations-demo-user-rpc-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 引入 SpringMVC 的 Spring Boot 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 实现对 SOFARPC 的自动化配置 -->
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>rpc-sofa-boot-starter</artifactId>
</dependency>
<!-- 使用 Zookeeper 作为注册中心 -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,15 @@
package cn.iocoder.springboot.lab62.rpc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
//@ImportResource("classpath:sofarpc.xml")
public class ConsumerApplication {
public static void main(String[] args) {
// 启动 Spring Boot 应用
SpringApplication.run(ConsumerApplication.class, args);;
}
}

View File

@@ -0,0 +1,32 @@
package cn.iocoder.springboot.lab62.rpc.controller;
import cn.iocoder.springboot.lab62.rpc.api.UserRpcService;
import cn.iocoder.springboot.lab62.rpc.dto.UserAddDTO;
import cn.iocoder.springboot.lab62.rpc.dto.UserDTO;
import com.alipay.sofa.runtime.api.annotation.SofaReference;
import com.alipay.sofa.runtime.api.annotation.SofaReferenceBinding;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user")
public class UserController {
@SofaReference(binding = @SofaReferenceBinding(bindingType = "bolt"))
private UserRpcService userRpcService;
@GetMapping("/get")
public UserDTO get(@RequestParam("id") Integer id) {
return userRpcService.get(id);
}
@GetMapping("/add") // 为了方便测试,实际使用 @PostMapping
public Integer add(@RequestParam("name") String name,
@RequestParam("gender") Integer gender) {
UserAddDTO addDTO = new UserAddDTO().setName(name).setGender(gender);
return userRpcService.add(addDTO);
}
}

View File

@@ -0,0 +1,5 @@
spring:
application:
name: user-service-consumer # 应用名
com.alipay.sofa.rpc.registry.address: zookeeper://127.0.0.1:2181 # SOFARPC 注解中心

View File

@@ -0,0 +1,56 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<!-- <artifactId>lab-62-sofarpc-xml-demo</artifactId>-->
<!-- <groupId>cn.iocoder.springboot.labs</groupId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<groupId>com.alipay.sofa</groupId>
<artifactId>sofaboot-dependencies</artifactId>
<version>3.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-62-sofarpc-annotations-demo-user-rpc-service-provider</artifactId>
<!-- <dependencyManagement>-->
<!-- <dependencies>-->
<!-- <dependency>-->
<!-- <groupId>com.alipay.sofa</groupId>-->
<!-- <artifactId>sofaboot-dependencies</artifactId>-->
<!-- <version>3.3.2</version>-->
<!-- <type>pom</type>-->
<!-- </dependency>-->
<!-- </dependencies>-->
<!-- </dependencyManagement>-->
<dependencies>
<!-- 引入定义的 SOFARPC API 接口 -->
<dependency>
<groupId>cn.iocoder.springboot.labs</groupId>
<artifactId>lab-62-sofarpc-annotations-demo-user-rpc-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 引入 Spring Boot 基础 Starter 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- 实现对 SOFARPC 的自动化配置 -->
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>rpc-sofa-boot-starter</artifactId>
</dependency>
<!-- 使用 Zookeeper 作为注册中心 -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,15 @@
package cn.iocoder.springboot.lab62.rpc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
//@ImportResource("classpath:sofarpc.xml")
public class ProviderApplication {
public static void main(String[] args) {
// 启动 Spring Boot 应用
SpringApplication.run(ProviderApplication.class, args);
}
}

View File

@@ -0,0 +1,27 @@
package cn.iocoder.springboot.lab62.rpc.service;
import cn.iocoder.springboot.lab62.rpc.api.UserRpcService;
import cn.iocoder.springboot.lab62.rpc.dto.UserAddDTO;
import cn.iocoder.springboot.lab62.rpc.dto.UserDTO;
import com.alipay.sofa.runtime.api.annotation.SofaService;
import com.alipay.sofa.runtime.api.annotation.SofaServiceBinding;
import org.springframework.stereotype.Service;
@Service
@SofaService(bindings = @SofaServiceBinding(bindingType = "bolt"))
public class UserRpcServiceImpl implements UserRpcService {
@Override
public UserDTO get(Integer id) {
return new UserDTO().setId(id)
.setName("没有昵称:" + id)
.setGender(id % 2 + 1); // 1 - 男2 - 女
}
@Override
public Integer add(UserAddDTO addDTO) {
return (int) (System.currentTimeMillis() / 1000); // 嘿嘿,随便返回一个 id
}
}

View File

@@ -0,0 +1,5 @@
spring:
application:
name: user-service-provider # 应用名
com.alipay.sofa.rpc.registry.address: zookeeper://127.0.0.1:2181 # SOFA RPC 注册中心

View File

@@ -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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>lab-62</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-62-sofarpc-annotations-demo</artifactId>
<packaging>pom</packaging>
<modules>
<module>lab-62-sofarpc-annotations-demo-user-rpc-service-api</module>
<module>lab-62-sofarpc-annotations-demo-user-rpc-service-provider</module>
<module>lab-62-sofarpc-annotations-demo-user-rpc-service-consumer</module>
</modules>
</project>

View File

@@ -1,12 +1,10 @@
package cn.iocoder.springboot.lab62.rpc.controller;
import cn.iocoder.springboot.lab62.rpc.api.UserRpcService;
import cn.iocoder.springboot.lab62.rpc.dto.UserAddDTO;
import cn.iocoder.springboot.lab62.rpc.dto.UserDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/user")
@@ -20,4 +18,11 @@ public class UserController {
return userRpcService.get(id);
}
@GetMapping("/add") // 为了方便测试,实际使用 @PostMapping
public Integer add(@RequestParam("name") String name,
@RequestParam("gender") Integer gender) {
UserAddDTO addDTO = new UserAddDTO().setName(name).setGender(gender);
return userRpcService.add(addDTO);
}
}

View File

@@ -2,4 +2,4 @@ spring:
application:
name: user-service-consumer # 应用名
com.alipay.sofa.rpc.registry.address: zookeeper://127.0.0.1:2181 # SOFA RPC 注解中心
com.alipay.sofa.rpc.registry.address: zookeeper://127.0.0.1:2181 # SOFARPC 注解中心

View File

@@ -8,7 +8,7 @@
<!-- <version>1.0-SNAPSHOT</version>-->
<groupId>com.alipay.sofa</groupId>
<artifactId>sofaboot-dependencies</artifactId>
<version>3.3.2</version>
<version>3.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -33,7 +33,7 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 引入 Spring Boot 基础 starter 依赖 -->
<!-- 引入 Spring Boot 基础 Starter 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>

View File

@@ -2,4 +2,4 @@ spring:
application:
name: user-service-provider # 应用名
com.alipay.sofa.rpc.registry.address: zookeeper://127.0.0.1:2181 # SOFA RPC 注中心
com.alipay.sofa.rpc.registry.address: zookeeper://127.0.0.1:2181 # SOFA RPC 注中心

View File

@@ -14,6 +14,7 @@
<modules>
<module>lab-62-sofarpc-xml-demo</module>
<module>lab-62-sofarpc-annotations-demo</module>
</modules>
</project>

0
lab-62/《》.md Normal file
View File

View File

@@ -0,0 +1,45 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<!-- <artifactId>lab-63-sofarpc-xml-demo</artifactId>-->
<!-- <groupId>cn.iocoder.springboot.labs</groupId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<groupId>com.alipay.sofa</groupId>
<artifactId>sofaboot-dependencies</artifactId>
<version>3.3.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-63-sofarpc-xml-demo-user-rpc-service-consumer</artifactId>
<dependencies>
<!-- 引入定义的 SOFARPC API 接口 -->
<dependency>
<groupId>cn.iocoder.springboot.labs</groupId>
<artifactId>lab-63-sofarpc-xml-demo-user-rpc-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 引入 SpringMVC 的 Spring Boot 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 实现对 SOFARPC 的自动化配置 -->
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>rpc-sofa-boot-starter</artifactId>
</dependency>
<!-- 使用 Zookeeper 作为注册中心 -->
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,16 @@
package cn.iocoder.springboot.lab63.rpc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@ImportResource("classpath:sofarpc.xml")
public class ConsumerApplication {
public static void main(String[] args) {
// 启动 Spring Boot 应用
SpringApplication.run(ConsumerApplication.class, args);;
}
}

View File

@@ -0,0 +1,28 @@
package cn.iocoder.springboot.lab63.rpc.controller;
import cn.iocoder.springboot.lab63.rpc.api.UserRpcService;
import cn.iocoder.springboot.lab63.rpc.dto.UserAddDTO;
import cn.iocoder.springboot.lab63.rpc.dto.UserDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
private UserRpcService userRpcService;
@GetMapping("/get")
public UserDTO get(@RequestParam("id") Integer id) {
return userRpcService.get(id);
}
@GetMapping("/add") // 为了方便测试,实际使用 @PostMapping
public Integer add(@RequestParam("name") String name,
@RequestParam("gender") Integer gender) {
UserAddDTO addDTO = new UserAddDTO().setName(name).setGender(gender);
return userRpcService.add(addDTO);
}
}

View File

@@ -0,0 +1,5 @@
spring:
application:
name: user-service-consumer # 应用名
com.alipay.sofa.rpc.registry.address: zookeeper://127.0.0.1:2181 # SOFARPC 注解中心

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sofa="http://sofastack.io/schema/sofaboot"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://sofastack.io/schema/sofaboot http://sofastack.io/schema/sofaboot.xsd">
<sofa:reference id="userRpcService" interface="cn.iocoder.springboot.lab63.rpc.api.UserRpcService">
<sofa:binding.bolt/>
</sofa:reference>
</beans>

View File

@@ -0,0 +1,14 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>lab-63-motan-xml-demo</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-63-motan-xml-demo-user-rpc-service-api</artifactId>
</project>

View File

@@ -0,0 +1,27 @@
package cn.iocoder.springboot.lab63.rpc.api;
import cn.iocoder.springboot.lab63.rpc.dto.UserAddDTO;
import cn.iocoder.springboot.lab63.rpc.dto.UserDTO;
/**
* 用户服务 RPC Service 接口
*/
public interface UserRpcService {
/**
* 根据指定用户编号,获得用户信息
*
* @param id 用户编号
* @return 用户信息
*/
UserDTO get(Integer id);
/**
* 添加新用户,返回新添加的用户编号
*
* @param addDTO 添加的用户信息
* @return 用户编号
*/
Integer add(UserAddDTO addDTO);
}

View File

@@ -0,0 +1,37 @@
package cn.iocoder.springboot.lab63.rpc.dto;
import java.io.Serializable;
/**
* 用户添加 DTO
*/
public class UserAddDTO implements Serializable {
/**
* 昵称
*/
private String name;
/**
* 性别
*/
private Integer gender;
public String getName() {
return name;
}
public UserAddDTO setName(String name) {
this.name = name;
return this;
}
public Integer getGender() {
return gender;
}
public UserAddDTO setGender(Integer gender) {
this.gender = gender;
return this;
}
}

View File

@@ -0,0 +1,49 @@
package cn.iocoder.springboot.lab63.rpc.dto;
import java.io.Serializable;
/**
* 用户信息 DTO
*/
public class UserDTO implements Serializable {
/**
* 用户编号
*/
private Integer id;
/**
* 昵称
*/
private String name;
/**
* 性别
*/
private Integer gender;
public Integer getId() {
return id;
}
public UserDTO setId(Integer id) {
this.id = id;
return this;
}
public String getName() {
return name;
}
public UserDTO setName(String name) {
this.name = name;
return this;
}
public Integer getGender() {
return gender;
}
public UserDTO setGender(Integer gender) {
this.gender = gender;
return this;
}
}

View File

@@ -0,0 +1,77 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>lab-63-motan-xml-demo</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-63-motan-xml-demo-user-rpc-service-provider</artifactId>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<spring.boot.version>2.2.4.RELEASE</spring.boot.version>
<moton.version>1.1.8</moton.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- 引入定义的 SOFARPC API 接口 -->
<dependency>
<groupId>cn.iocoder.springboot.labs</groupId>
<artifactId>lab-63-motan-xml-demo-user-rpc-service-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<!-- 引入 Spring Boot 基础 Starter 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- 实现对 SOFARPC 的自动化配置 -->
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-core</artifactId>
<version>${moton.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-transport-netty</artifactId>
<version>${moton.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-registry-zookeeper</artifactId>
<version>${moton.version}</version>
</dependency>
<dependency>
<groupId>com.weibo</groupId>
<artifactId>motan-springsupport</artifactId>
<version>${moton.version}</version>
</dependency>
<!-- 使用 Zookeeper 作为注册中心 -->
<!-- <dependency>-->
<!-- <groupId>org.apache.curator</groupId>-->
<!-- <artifactId>curator-framework</artifactId>-->
<!-- </dependency>-->
</dependencies>
</project>

View File

@@ -0,0 +1,16 @@
package cn.iocoder.springboot.lab63.rpc;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ImportResource;
@SpringBootApplication
@ImportResource("classpath:sofarpc.xml")
public class ProviderApplication {
public static void main(String[] args) {
// 启动 Spring Boot 应用
SpringApplication.run(ProviderApplication.class, args);
}
}

View File

@@ -0,0 +1,24 @@
package cn.iocoder.springboot.lab63.rpc.service;
import cn.iocoder.springboot.lab63.rpc.api.UserRpcService;
import cn.iocoder.springboot.lab63.rpc.dto.UserAddDTO;
import cn.iocoder.springboot.lab63.rpc.dto.UserDTO;
import org.springframework.stereotype.Service;
@Service
public class UserRpcServiceImpl implements UserRpcService {
@Override
public UserDTO get(Integer id) {
return new UserDTO().setId(id)
.setName("没有昵称:" + id)
.setGender(id % 2 + 1); // 1 - 男2 - 女
}
@Override
public Integer add(UserAddDTO addDTO) {
return (int) (System.currentTimeMillis() / 1000); // 嘿嘿,随便返回一个 id
}
}

View File

@@ -0,0 +1,5 @@
spring:
application:
name: user-service-provider # 应用名
com.alipay.sofa.rpc.registry.address: zookeeper://127.0.0.1:2181 # SOFA RPC 注册中心

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sofa="http://sofastack.io/schema/sofaboot"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://sofastack.io/schema/sofaboot http://sofastack.io/schema/sofaboot.xsd">
<sofa:service ref="userRpcServiceImpl" interface="cn.iocoder.springboot.lab63.rpc.api.UserRpcService">
<sofa:binding.bolt/>
</sofa:service>
</beans>

View File

@@ -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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>lab-63</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-63-motan-xml-demo</artifactId>
<packaging>pom</packaging>
<modules>
<module>lab-63-motan-xml-demo-user-rpc-service-api</module>
<module>lab-63-motan-xml-demo-user-rpc-service-provider</module>
<!-- <module>lab-63-sofarpc-xml-demo-user-rpc-service-consumer</module>-->
</modules>
</project>

18
lab-63/pom.xml Normal file
View File

@@ -0,0 +1,18 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>labs-parent</artifactId>
<groupId>cn.iocoder.springboot.labs</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>lab-63</artifactId>
<modules>
<module>lab-63-motan-xml-demo</module>
</modules>
</project>

View File

@@ -72,6 +72,8 @@
<!-- <module>lab-59</module>-->
<!-- <module>lab-60</module>-->
<!-- <module>lab-61</module>-->
<module>lab-62</module>
<module>lab-63</module>
<!-- Spring Cloud 示例 -->
<!-- <module>labx-01</module>-->
@@ -100,7 +102,7 @@
<!-- <module>labx-24</module>-->
<!-- <module>labx-25</module>-->
<!-- <module>labx-26</module>-->
<module>lab-62</module>
</modules>
</project>