资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

Dubbo如何实现调用

今天就跟大家聊聊有关Dubbo如何实现调用,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

成都创新互联公司长期为超过千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为三原企业提供专业的成都做网站、成都网站设计,三原网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。

 

1、创建maven工程(打包方式为war)dubbodemo_provider,在pom.xml文件中导入如下坐标

 

~~~xml

  UTF-8

  1.8

  1.8

  5.0.5.RELEASE

 

    org.springframework

    spring-context

    ${spring.version}

 

 

    org.springframework

    spring-beans

    ${spring.version}

 

 

    org.springframework

    spring-webmvc

    ${spring.version}

 

 

    org.springframework

    spring-jdbc

    ${spring.version}

 

 

    org.springframework

    spring-aspects

    ${spring.version}

 

 

    org.springframework

    spring-jms

    ${spring.version}

 

 

    org.springframework

    spring-context-support

    ${spring.version}

 

 

 

    com.alibaba

    dubbo

    2.6.0

 

 

    org.apache.zookeeper

    zookeeper

    3.4.7

 

 

    com.github.sgroschupf

    zkclient

    0.1

 

 

    javassist

    javassist

    3.12.1.GA

 

 

    com.alibaba

    fastjson

    1.2.47

 

 

   

      org.apache.maven.plugins

      maven-compiler-plugin

      2.3.2

     

        1.8

        1.8

     

   

   

      org.apache.tomcat.maven

      tomcat7-maven-plugin

     

       

        8081

       

        /

     

   

 

~~~

 

2、配置web.xml文件

 

~~~xml

 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

 "http://java.sun.com/dtd/web-app_2_3.dtd" >

  Archetype Created Web Application

 

    contextConfigLocation

    classpath:applicationContext*.xml

 

 

    org.springframework.web.context.ContextLoaderListener

 

 

~~~

 

3、创建服务接口

 

~~~java

package com.itheima.service;

public interface HelloService {

    public String sayHello(String name);

}

~~~

 

4、创建服务实现类

 

~~~java

package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;

import com.itheima.service.HelloService;

 

@Service

public class HelloServiceImpl implements HelloService {

    public String sayHello(String name) {

        return "hello " + name;

    }

}

~~~

 

注意:服务实现类上使用的Service注解是Dubbo提供的,用于对外发布服务

 

5、在src/main/resources下创建applicationContext-service.xml

 

~~~xml

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xmlns:p="http://www.springframework.org/schema/p"

                   xmlns:context="http://www.springframework.org/schema/context"

                   xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"

             xmlns:mvc="http://www.springframework.org/schema/mvc"

                   xsi:schemaLocation="http://www.springframework.org/schema/beans

                   http://www.springframework.org/schema/beans/spring-beans.xsd

         http://www.springframework.org/schema/mvc

         http://www.springframework.org/schema/mvc/spring-mvc.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.xsd">

        

        

        

        

        

        

        

        

~~~

 

6、启动服务

 

tomcat7:run

看完上述内容,你们对Dubbo如何实现调用有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。


新闻名称:Dubbo如何实现调用
分享网址:http://cdkjz.cn/article/ggccgj.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220