最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

dubbo服務(wù)無法注冊到zookeeper的問題

 更新時間:2025年07月16日 09:46:30   作者:VenMan  
Dubbo+Zookeeper項目服務(wù)注冊失敗,因模塊創(chuàng)建時誤選Web項目導致main下文件夾名為data,服務(wù)未被識別,更改為java后,服務(wù)正常注冊,Zookeeper心跳及接口調(diào)用問題解決

Dubbo+Zookeeper后臺項目中服務(wù)注冊不上

1、接口調(diào)用時頁面報404,后臺發(fā)現(xiàn)不了請求的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、服務(wù)啟動后一直沒有收到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、掃描不到服務(wù)

2、地址攔截,請求不通過

3、因為使用了dubbo,在導包注解可能存在導錯其他包

排查

1、翻看多次配置,發(fā)現(xiàn)能正常掃描到指定controller文件

<web-app>
<!--提供外部接口訪問-->
  <servlet>
    <servlet-name>springmvc</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  <init-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:spring-mvc.xml</param-value>
  </init-param>
<!--初始化容器-->
    <load-on-startup>1</load-on-startup>
  </servlet>
<!--匹配-->
  <servlet-mapping>
    <servlet-name>springmvc</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>
</web-app>
<beans>
    <!--mvc注解驅(qū)動-->
    <mvc:annotation-driven></mvc:annotation-driven>
    <!--dubbo包掃描-->
    <dubbo:annotation package="com.happy.web"></dubbo:annotation>
    <!--注冊中心-->
    <dubbo:registry address="zookeeper://127.0.0.1:2181"></dubbo:registry>
    <!--應(yīng)用名稱-->
    <dubbo:application name="happy-web"></dubbo:application>
    <!--消費端啟動檢查-->
    <dubbo:consumer check="false" timeout="6000000"></dubbo:consumer>
</beans>

2、tomcat中配置了任何請求都可以到達

<project>
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <!--指定端口-->
                    <port>82</port>
                    <!--請求路徑-->
                    <path>/</path>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

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<Custmer> findAll() {
        List<Custmer> 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<Custmer> findAll() {
        return custmerMapper.findAll();
    }
}

以上問題解決方法都試過后,發(fā)現(xiàn)不符合本次問題解決方式。項目之前有過做過,經(jīng)過多次對比也沒有發(fā)現(xiàn)有什么不同之處,最后找朋友看了下,才發(fā)現(xiàn)問題

本次問題的原因

  • 在建立模塊時選擇了web項目

  • main下面自動生成的文件夾名為data,導致服務(wù)找不到

本次問題的解決方法

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

接口調(diào)用正常:

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.pojo.Custmer> 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

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

邛崃市| 邮箱| 怀柔区| 商洛市| 蒙城县| 普宁市| 曲沃县| 二连浩特市| 临汾市| 常州市| 慈溪市| 金坛市| 共和县| 杭锦后旗| 雷山县| 塔城市| 沁源县| 荃湾区| 石楼县| 平定县| 东辽县| 临夏县| 马公市| 汝城县| 手游| 宁武县| 河间市| 达拉特旗| 米林县| 措勤县| 宁南县| 汉源县| 成武县| 上饶县| 高唐县| 民丰县| 康定县| 专栏| 富宁县| 项城市| 武强县|