• 1
  • 2
  • 3
  • 4
  • 5

高中生大学生毕业后必选职业路

Dubbox服务消费方六个详细的开发步骤!

再怎么慎重都不为过

免费咨询 >
相关IT课程
Dubbox服务消费方六个详细的开发步骤!
这些IT技术课程很火爆,你还在等什么?
怎么学好 学什么好 咋学快速
网络营销 以在线咨询为准 热招
HTML5定制班HTML5定制班热招 以在线咨询为准 热招
Python定制班Python定制班热招 以在线咨询为准 热招
软件测试就业班软件测试就业班热招 以在线咨询为准 热招
JAVA就业班JAVA就业班热招 以在线咨询为准 热招
UI设计定制班 以在线咨询为准 热招

全移动智能化教学设施

定义"高大上"

让你学习高薪技术专业轻松无忧快乐

  • Java开发工程师
  • PHP培训
  • web全栈工程师
  • 软件测试工程师
  • 人工智能培训
  • 云计算培训
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Dubbox服务消费方六个详细的开发步骤!

你想不优秀,没门!

专业选择对了,努力才能不白费

大数据-Dubbox服务消费方六个详细的开发步骤!
UI培训-Dubbox服务消费方六个详细的开发步骤!
网络营销-Dubbox服务消费方六个详细的开发步骤!
直播带货-Dubbox服务消费方六个详细的开发步骤!
物联网-Dubbox服务消费方六个详细的开发步骤!

Dubbox服务消费方六个详细的开发步骤!


Dubbox服务消费方开发详解,具体内容包括六个详细的开发步骤。Dubbox服务消费方开发详解如下:

1、创建maven工程(打包方式为war)dubbodemo_consumer,pom.xml配置和上面服务提供者相同,只需要将Tomcat插件的端口号改为8082即可。

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

springmvc

org.springframework.web.servlet.DispatcherServlet

contextConfigLocation

classpath:applicationContext-web.xml

1

springmvc

*.do

~~~

3、将服务提供者工程中的HelloService接口复制到当前工程

4、编写Controller

~~~java

package com.itheima.controller;

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

import com.itheima.service.HelloService;

import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.ResponseBody;

@Controller

@RequestMapping("/demo")

public class HelloController {

@Reference

private HelloService helloService;

@RequestMapping("/hello")

@ResponseBody

public String getName(String name){

//远程调用

String result = helloService.sayHello(name);

System.out.println(result);

return result;

}

}

~~~

注意:Controller中注入HelloService使用的是Dubbo提供的@Reference注解

5、在src/main/resources下创建applicationContext-web.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启动

在浏览器输入http://localhost:8082/demo/hello.do?name=Jack,查看浏览器输出结果。

以上就是Dubbox服务消费方开发详解的全部内容,大家都看懂了吗?如果想要学习更多有关Dubbox的内容,可以继续关注IT培训网资讯Java栏目,我们将不定期更新学习资源~

全国1000多家名企招聘

500家企业人才定制培养需求

想不就业,太难!

IT培训就业之一 IT培训就业之二 IT培训就业之三
学员最关心的就业问题
想学员之所想,解学员之所惑
我怎么样选择
合适的IT课程?

我怎么样选择合适的IT课程?-Dubbox服务消费方六个详细的开发步骤!

学了IT课程后
能保证就业吗?

学了IT课程后能保证就业吗?-Dubbox服务消费方六个详细的开发步骤!

学了IT后可以进
哪些企业?

学了IT后可以进哪些企业?-Dubbox服务消费方六个详细的开发步骤!

0基础
学什么专业更好?

0基础学什么专业更好?-Dubbox服务消费方六个详细的开发步骤!

IT培训网课程的
优势有哪些?

IT培训网课程的优势有哪些?-Dubbox服务消费方六个详细的开发步骤!

IT课程学费多少钱?

IT课程费多少钱?-Dubbox服务消费方六个详细的开发步骤!

版权所有:IT培训网 备案信息:中国优质IT培训网

课程免费咨询热线:13783581536