dubbo入门

新建一个空项目,再建2个module:provider,consumer

用到以下依赖及插件,pom文件如下:


    org.springframework
    spring-context
    5.2.4.RELEASE
  
  
    org.springframework
    spring-beans
    5.2.4.RELEASE
  
  
    org.springframework
    spring-webmvc
    5.2.4.RELEASE
  
  
    org.springframework
    spring-jdbc
    5.2.4.RELEASE
  
  
    org.springframework
    spring-aspects
    5.2.4.RELEASE
  
  
    org.springframework
    spring-jms
    5.2.4.RELEASE
  
  
    org.springframework
    spring-context-support
    5.2.4.RELEASE
  
  
    com.alibaba
    fastjson
    1.2.47
  

  
  
    com.alibaba
    dubbo
    2.6.6
    
      
        spring-context
        org.springframework
      
      
        netty
        org.jboss.netty
      
    
  
  
    org.apache.zookeeper
    zookeeper
    3.4.14
  
    
    
    
      org.apache.curator
      curator-framework
      4.2.0
    
    
      org.apache.curator
      curator-recipes
      4.2.0
    

    
    
      io.netty
      netty-all
      4.1.42.Final
    
    
    
      org.javassist
      javassist
      3.20.0-GA
    
    
    
      com.101tec
      zkclient
      0.10
    
  
    junit
    junit
    4.11
    test
  


  
    pro
    
      
        org.apache.tomcat.maven
        tomcat7-maven-plugin
        
          8082
          /
        
      
    

在provider中提供服务,接口及实现类,目录结构如下所示:

dubbo入门_第1张图片

applicationContext-service.xml如下所示:



    
    
        
        
        
    

    
    

    
    

    

web.xml配置监听器,加载spring容器




  Archetype Created Web Application
  
    contextConfigLocation
    classpath:applicationContext-service.xml
  
  
    org.springframework.web.context.ContextLoaderListener
  

 

consumer中的controller及文件结构如下所示

dubbo入门_第2张图片

 web.xml:



  
  Archetype Created Web Application
  
    consumer
    org.springframework.web.servlet.DispatcherServlet
    
    
      contextConfigLocation
      classpath:applicationContext-web.xml
    
    1
  
  
    consumer
    
    /
  

applicationContext-web.xml 




    
    
        
            
                
            
        
    
    
    
        
        
        
    
    

    

 注意一下:context:component-scan的设置,否则会出现 错误,,,

测试:http://localhost:8081/sa?name=po

 

你可能感兴趣的:(dubbo入门)