dubbo 点对点消费端

pom 中尽量排除 slf4j


        org.springframework
        spring-context
        5.3.6
   


       
            com.alibaba
            dubbo
            2.6.6
       

       
            服务端项目组
        服务端项目名
        版本
        
            
                org.slf4j
                slf4j-api
            

        

       

public class Consumer {
    
    public static void main(String[] args) throws Exception {
           ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("consumer.xml");
            context.start();
            ProviderService providerService =(ProviderService)context.getBean("providerService");
            String hello = providerService.SayHello("hello");
            System.out.println( hello ); // 显示调用结果
        }
}
 

consumer.xml


    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
    xsi:schemaLocation="http://www.springframework.org/schema/beans        http://www.springframework.org/schema/beans/spring-beans-4.3.xsd        http://dubbo.apache.org/schema/dubbo        http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
 
   
   
     
   
   

 
   
        interface="com.www.service.ProviderService"
    url="dubbo://127.0.0.1:8005/com.www.service.ProviderService" />

注意版本号不然会找不到报错

Caused by: com.alibaba.dubbo.remoting.RemotingException: com.alibaba.dubbo.remoting.RemotingException: Not found exported service xxxx

may be version or group mismatch

你可能感兴趣的:(Java,dubbo,java,spring)