踩坑日志:
配置的yml文件 记得开启服务包扫描
dubbo:
registry:
address: zookeeper://127.0.0.1:2181 #注册中心
protocol:
name: dubbo #协议名称
scan:
base-packages: top.klausmax.service.impl #服务包扫描
序列化反序列化要记得实现标准类的
implements Serializable
公共api接口处
public interface UserService extends IService<User> {}
service层
mapper
@Repository
public interface UserMapper extends BaseMapper<User> {
}
实现类
@DubboService(timeout = 50000)
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
}
@SpringBootApplication
@MapperScan("com.itheima.mapper")
public class ServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ServiceApplication.class,args);
}
}
WEB层
@RestController
@RequestMapping("/user")
public class UserController {
@DubboReference(check = false)
private UserService userService;
@RequestMapping("/findAll")
public List<User> findAll() {
return userService.list();
}
}