栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

dubbo服务无法注册到zookeeper

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

dubbo服务无法注册到zookeeper

Dubbo+Zookeeper后台项目中服务注册不上

1、接口调用时页面报404,后台发现不了请求的url

19:51:56,458 DEBUG DispatcherServlet:891 - DispatcherServlet with name 'springmvc' processing GET request for [/custmer/findAll.do]
19:51:56,460 DEBUG RequestMappingHandlerMapping:312 - Looking up handler method for path /custmer/findAll.do
19:51:56,461 DEBUG RequestMappingHandlerMapping:322 - Did not find handler method for [/custmer/findAll.do]
19:51:56,462  WARN PageNotFound:1205 - No mapping found for HTTP request with URI [/custmer/findAll.do] in DispatcherServlet with name 'springmvc'
19:51:56,462 DEBUG DispatcherServlet:1000 - Successfully completed request

2、服务启动后一直没有收到zookeeper心跳机制的反馈,正常情况下日志中会打印出来

19:51:20,214  INFO DispatcherServlet:509 - FrameworkServlet 'springmvc': initialization completed in 1771 ms
19:51:20,214 DEBUG DispatcherServlet:175 - Servlet 'springmvc' configured successfully
五月 03, 2022 7:51:20 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-82"]

可能存在的问题:

1、扫描不到服务
2、地址拦截,请求不通过
3、因为使用了dubbo,在导包注解可能存在导错其他包


排查:

1、翻看多次配置,发现能正常扫描到指定controller文件



  
    springmvc
    org.springframework.web.servlet.DispatcherServlet
  
    contextConfigLocation
    classpath*:spring-mvc.xml
  

    1
  

  
    springmvc
    *.do
  


    
    
    
    
    
    
    
    
    
    

2、tomcat中配置了任何请求都可以到达


  
        
            
                org.apache.tomcat.maven
                tomcat7-maven-plugin
                
                    
                    82
                    
                    /
                
            
        
    

3、controller和service中导入的包正常

import com.alibaba.dubbo.config.annotation.Reference;
import com.happy.pojo.Custmer;
import com.happy.service.CustmerService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/custmer")
public class CustmerController {

    @Reference
    CustmerService custmerService;

    @RequestMapping("/findAll")
    public List findAll() {
        List all = custmerService.findAll();
        return all;
    }
}
import com.alibaba.dubbo.config.annotation.Service;
import com.happy.dao.CustmerMapper;
import com.happy.pojo.Custmer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = CustmerService.class)
@Transactional
public class CustmerServiceImpl implements CustmerService {
    @Autowired
    CustmerMapper custmerMapper;

    @Override
    public List findAll() {
        return custmerMapper.findAll();
    }
}

以上问题解决方法都试过后,发现不符合本次问题解决方式。项目之前有过做过,经过多次对比也没有发现有什么不同之处,最后找朋友看了下,才发现问题

本次问题的原因:

在建立模块时选择了web项目

main下面自动生成的文件夹名为data,导致服务找不到

本次问题的解决方法:

main下面的文件名更改为java后正常

zookeeper心跳机制正常:

20:32:51,927  INFO DispatcherServlet:509 - FrameworkServlet 'springmvc': initialization completed in 3575 ms
20:32:51,927 DEBUG DispatcherServlet:175 - Servlet 'springmvc' configured successfully
五月 03, 2022 8:32:51 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-82"]
20:32:56,208 DEBUG ClientCnxn:766 - Got notification sessionid:0x18089b835320006

接口调用正常:

20:33:29,254 DEBUG DispatcherServlet:891 - DispatcherServlet with name 'springmvc' processing GET request for [/custmer/findAll.do]
20:33:29,255 DEBUG RequestMappingHandlerMapping:312 - Looking up handler method for path /custmer/findAll.do
20:33:29,259 DEBUG RequestMappingHandlerMapping:319 - Returning handler method [public java.util.List com.happy.web.CustmerController.findAll()]
20:33:29,259 DEBUG DefaultListableBeanFactory:254 - Returning cached instance of singleton bean 'custmerController'
20:33:29,260 DEBUG DispatcherServlet:979 - Last-Modified value for [/custmer/findAll.do] is: -1
20:33:34,892 DEBUG DecodeHandler:58 -  [DUBBO] Decode decodeable message com.alibaba.dubbo.rpc.protocol.dubbo.DecodeableRpcResult, dubbo version: 2.6.0, current host: 192.168.1.115
20:33:34,967 DEBUG RequestResponseBodyMethodProcessor:277 - Written [[Custmer(id=1, name=小王), Custmer(id=2, name=小杨), Custmer(id=3, name=小刘), Custmer(id=4, name=小李)]] as "application/json" using [org.springframework.http.converter.json.GsonHttpMessageConverter@3b3104b1]
20:33:34,969 DEBUG DispatcherServlet:1076 - Null ModelAndView returned to DispatcherServlet with name 'springmvc': assuming HandlerAdapter completed request handling
20:33:34,971 DEBUG DispatcherServlet:1000 - Successfully completed request
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/854608.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号