dubbo消费者怎么配置包路径

来源:5-4 测试集群角色以及选举

qq_君君晨晨_0

2021-03-15

我已经配置好了生产者,如下图所示
图片描述

我想在消费端调用这个服务,但是显示找不到服务,提示如下:
No provider available for the service com.bnuz.yjpj.datastatistics.service.CourseStatisticsService
说找不到服务com.bnuz.yjpj.datastatistics.service.CourseStatisticsService
我对比了一下,发现是包路径不对,我该怎样在消费者中配置包路径以确保它们俩能一样?找了半天找不到在哪里配置包路径
下面是消费者代码

package com.bnuz.yjpj.datastatistics.web;

import com.bnuz.yjpj.common.dto.DataReturnDto;
import com.bnuz.yjpj.datastatistics.service.CourseStatisticsService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据统计-课程统计
 *
 * @author ZhangChen
 **/
@RestController
@RequestMapping("/api/CourseStatistics")
public class SubjectStatistics {
    @DubboReference
    CourseStatisticsService courseStatisticsService;

    @RequestMapping("/getClassSubjectStatistics")
    public DataReturnDto getClassSubjectStatistics(String classId, Integer week, String teacherId){
        DataReturnDto classSubjectStatistics = courseStatisticsService.getClassSubjectStatistics(classId, week, teacherId);
        return classSubjectStatistics;
    }
}

按照生产者路径在消费者中建立了对应的包路径就调用成功了

图片描述

写回答

1回答

风间影月

2021-03-15

猜测你的项目出了配置问题,应该是哪里的细节没有注意噢~
现在基本上很少有项目用dubbo开发了额~~

0
3
qq_君君晨晨_0
非常感谢!
2021-03-15
共3条回复

ZK分布式专题与Dubbo微服务入门,成长与加薪必备

进阶中高级工程师必备技能,大数据与微服务最常用的中间件

1859 学习 · 321 问题

查看课程