springboot集成dubbo

摘要  springboot国外用的比较多,而dubbo国外又很少用,所有集成例子比较少。
spring  springboot  dubbo

  1. dubbo XML文件引用:@ImportResource("classpath:dubbo-consum.xml")

  2. 有的springboot版本会出现,dubbo注册服务的xml文件中引用的service报错不能注入,需要加入

  3. dubbo XSD文件需要手动导入到开发工具中

  4. 最头疼的一个,就是版本冲突,首先是dubbo与spring的冲突,然后是zk与sf4j的冲突。


  5. ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
                 org.springframework.boot
                 spring-boot-starter-web
                 ${spring.boot.version}
            
             
            
                 com.alibaba
                 dubbo
                 2.5 . 3
                
                    
                         org.springframework
                         spring
                    
                
            
            
                 org.apache.zookeeper
                 zookeeper
                 3.4 . 6
                
                    
                         org.slf4j
                         slf4j-log4j12
                    
                    
                         log4j
                         log4j
                    
                
            
     
            
                 com.github.sgroschupf
                 zkclient
                 0.1
            
  6. ?
    1
    上面的maven引入springboot用的版本是 1.3 . 0
  7. ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    "1.0"  encoding= "UTF-8" ?>
    "http://www.springframework.org/schema/beans"
        xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:jee= "http://www.springframework.org/schema/jee"
         xmlns:tx= "http://www.springframework.org/schema/tx"
         xmlns:dubbo= "http://code.alibabatech.com/schema/dubbo"
         xmlns:context= "http://www.springframework.org/schema/context"
         xsi:schemaLocation="http: //www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
         http: //www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
         http: //www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd
         http: //code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
         http: //www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"
         default -lazy-init= "false"  >
       
        "dubbo-provider-dsp" >
        package = "pring.boot.*"  />
          
        "zookeeper://192.168.2.164:2181"  check= "false"  subscribe= "false"  register= "" >
         
       interface = "pring.boot.service.dubbo.DubboService"  ref= "dubboService"  />  
  8. ?
    1
    上面是生产者dubbo xml文件,文件放在resources中
  9. ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    @SpringBootApplication
    @ImportResource ( "classpath:dubbo-consum.xml" )
    public  class  Application {
     
         public  static  void  main(String[] args)  throws  Exception {
             SpringApplication.run(Application. class , args);
         }
     
    }
  10. ?
    1
    这是引用dubbo文件,生产者和消费者都是一样引入。
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"1.0"  encoding= "UTF-8" ?>  
"http://www.springframework.org/schema/beans"  
     xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"  
     xmlns:dubbo= "http://code.alibabatech.com/schema/dubbo"  
     xsi:schemaLocation="http: //www.springframework.org/schema/beans          
     http: //www.springframework.org/schema/beans/spring-beans.xsd          
     http: //code.alibabatech.com/schema/dubbo          
     http: //code.alibabatech.com/schema/dubbo/dubbo.xsd">  
       
     "dubbo-custom-dsp" />   
     "zookeeper://192.168.2.164:2181"  />  
       
     "dubboService"  interface = "pring.boot.service.dubbo.DubboService"  />  
这是消费者dubbo xml文件 文件位置跟生产者一样

你可能感兴趣的:(springboot集成dubbo)