《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!
1.2 dubbo-user-interface
package com.bobo.dubbo.service;
import com.bobo.pojo.User;
/**
-
将用户的CRUD四个操作我们拆成了4个服务,便于演示dubbo
-
实际开发过程中不用
-
@author dengp
*/
public interface AddUserDubboService {
void addUser(User user);
}
1.3 dubbo-user-service
package com.bobo.dubbo.service.impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.bobo.dubbo.service.AddUserDubboService;
import com.bobo.mapper.UsersMapper;
import com.bobo.pojo.User;
@Service
public class AddUserDubboServiceImpl implements AddUserDubboService {
@Resource
private UsersMapper userMapper;
@Override
public void addUser(User user) {
// TODO Auto-generated method stub
userMapper.insertUsers(user);
}
}
注意我们在服务端添加了服务,我们需要在Dubbo中注册该服务。
<?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:aop=“http://www.springframework.org/schema/aop”
xmlns:context=“http://www.springframework.org/schema/context” xmlns:tx=“http://www.springframework.org/schema/tx”
xmlns:dubbo=“http://code.alibabatech.com/schema/dubbo”
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xs