当前位置: 首页 > news >正文

建设旅行网站策划书2022最新免费的推广引流软件

建设旅行网站策划书,2022最新免费的推广引流软件,设计建设网站,普宁17网站一起做网店文章目录 一、生产者工程0.目录结构1.依赖2.配置文件3.启动类4.生产者服务 二、消费者工程0.目录结构1.依赖2.配置文件3.启动类4.服务接口5.controller接口 三、测试代码 本博客配套源码:gitlab仓库 首先,在服务器上部署zookeeper并运行,可以…

文章目录

  • 一、生产者工程
    • 0.目录结构
    • 1.依赖
    • 2.配置文件
    • 3.启动类
    • 4.生产者服务
  • 二、消费者工程
    • 0.目录结构
    • 1.依赖
    • 2.配置文件
    • 3.启动类
    • 4.服务接口
    • 5.controller接口
  • 三、测试代码

本博客配套源码:gitlab仓库

首先,在服务器上部署zookeeper并运行,可以参考我的另一篇教程:https://blog.csdn.net/Tracycoder/article/details/142792750

注意事项:

  • 生产者、消费者中服务的包路径一定要一致,不然会导致注册和消费失败!
  • 先启动生产者,再启动消费者!不然会启动失败!
  • 各依赖的版本一定要兼容,不然项目会启动失败!

一定要注意以上几点,踩了几个小时的坑,说多了都是泪!

一、生产者工程

0.目录结构

在这里插入图片描述

1.依赖

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>dubbo_study_provider</artifactId><version>1.0-SNAPSHOT</version><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.5.4</version><relativePath/> <!-- lookup parent from repository --></parent><dependencies><!-- Spring Boot Starter --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><!-- Dubbo Starter --><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-spring-boot-starter</artifactId><version>3.2.0</version></dependency><!-- Zookeeper Client --><dependency><groupId>org.apache.curator</groupId><artifactId>curator-framework</artifactId><version>5.4.0</version></dependency><dependency><groupId>org.apache.curator</groupId><artifactId>curator-recipes</artifactId><version>5.4.0</version></dependency><dependency><groupId>org.javassist</groupId><artifactId>javassist</artifactId><version>3.29.2-GA</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.curator/curator-x-discovery-server --><dependency><groupId>org.apache.curator</groupId><artifactId>curator-x-discovery-server</artifactId><version>5.4.0</version></dependency><!-- Spring Boot Test Starter --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies></project>

2.配置文件

applicaiton.yml

server:port: 8080# Dubbo
dubbo:application:name: dubbo_providerregistry:address: zookeeper://你的zookeeperIP:2181protocol:name: dubboport: 20880

3.启动类

package tracy;import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
@EnableDubbo(scanBasePackages = "tracy.provider.service")
public class ProviderApplication {public static void main(String[] args) {System.setProperty("zookeeper.sasl.client", "false");SpringApplication.run(ProviderApplication.class, args);System.out.println("provider服务启动成功!!!");}
}

4.生产者服务

package tracy.provider.service;public interface HelloService {String sayHello(String name);
}
package tracy.provider.service;import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Component;@DubboService(version = "1.0.0")
@Component
public class HelloServiceImpl implements HelloService {@Overridepublic String sayHello(String name) {return "hello "+name+"!";}
}

二、消费者工程

0.目录结构

在这里插入图片描述

1.依赖

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>dubbo_study_consumer</artifactId><version>1.0-SNAPSHOT</version><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.5.4</version><relativePath/> <!-- lookup parent from repository --></parent><dependencies><!-- Spring Boot Starter --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!-- Dubbo Starter --><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-spring-boot-starter</artifactId><version>3.2.0</version></dependency><!-- Zookeeper Client --><dependency><groupId>org.apache.curator</groupId><artifactId>curator-framework</artifactId><version>5.4.0</version></dependency><dependency><groupId>org.apache.curator</groupId><artifactId>curator-recipes</artifactId><version>5.4.0</version></dependency><dependency><groupId>org.javassist</groupId><artifactId>javassist</artifactId><version>3.29.2-GA</version></dependency><!-- https://mvnrepository.com/artifact/org.apache.curator/curator-x-discovery-server --><dependency><groupId>org.apache.curator</groupId><artifactId>curator-x-discovery-server</artifactId><version>5.4.0</version></dependency><!-- Spring Boot Test Starter --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies></project>

2.配置文件

application.yml

server:port: 8081# Dubbo
dubbo:application:name: dubbo_consumerregistry:address: zookeeper://你的zookeeperIP:2181consumer:check: false  # 设置为 false,避免消费者启动时检查提供者状态

3.启动类

package tracy;import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
@EnableDubbo
public class ConsumerApplication {public static void main(String[] args) {System.setProperty("zookeeper.sasl.client", "false");SpringApplication.run(ConsumerApplication.class, args);System.out.println("consumer服务启动成功!!!");}
}

4.服务接口

package tracy.provider.service;public interface HelloService {String sayHello(String name);
}

5.controller接口

package tracy.controller;import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import tracy.provider.service.HelloService;@RestController
@RequestMapping("/hello")
public class HelloController {@DubboReference  // 使用 DubboReference 注解引用远程服务private HelloService helloService;@GetMapping("/sayHello")public String sayHello(@RequestParam String name) {return helloService.sayHello(name);}
}

三、测试代码

先启动zookeeper,然后启动provider,最后启动consumer。

然后在接口测试工具中访问接口:

在这里插入图片描述

访问成功!


文章转载自:
http://middleweight.ddfp.cn
http://ribaldly.ddfp.cn
http://carnify.ddfp.cn
http://revisability.ddfp.cn
http://fremd.ddfp.cn
http://threepence.ddfp.cn
http://pluralism.ddfp.cn
http://hypophyllous.ddfp.cn
http://aweigh.ddfp.cn
http://substernal.ddfp.cn
http://grogram.ddfp.cn
http://deaf.ddfp.cn
http://loessial.ddfp.cn
http://postdiluvian.ddfp.cn
http://subtemperate.ddfp.cn
http://bellywhop.ddfp.cn
http://amebiasis.ddfp.cn
http://earshot.ddfp.cn
http://elding.ddfp.cn
http://sabugalite.ddfp.cn
http://tailgunning.ddfp.cn
http://ncu.ddfp.cn
http://khidmutgar.ddfp.cn
http://richina.ddfp.cn
http://scleroid.ddfp.cn
http://damageable.ddfp.cn
http://bubo.ddfp.cn
http://adjudgment.ddfp.cn
http://deemphasis.ddfp.cn
http://blub.ddfp.cn
http://perichondrium.ddfp.cn
http://upi.ddfp.cn
http://carnivorous.ddfp.cn
http://forepost.ddfp.cn
http://precool.ddfp.cn
http://hadst.ddfp.cn
http://brocket.ddfp.cn
http://townsman.ddfp.cn
http://crim.ddfp.cn
http://secularize.ddfp.cn
http://blear.ddfp.cn
http://softly.ddfp.cn
http://quinquina.ddfp.cn
http://ceaselessly.ddfp.cn
http://orthographical.ddfp.cn
http://reapportionment.ddfp.cn
http://adriatic.ddfp.cn
http://nineteenth.ddfp.cn
http://messerschmitt.ddfp.cn
http://busker.ddfp.cn
http://adorn.ddfp.cn
http://maoriland.ddfp.cn
http://lamella.ddfp.cn
http://emptying.ddfp.cn
http://hebrew.ddfp.cn
http://minitance.ddfp.cn
http://premix.ddfp.cn
http://conceivability.ddfp.cn
http://fernbrake.ddfp.cn
http://precipitation.ddfp.cn
http://laager.ddfp.cn
http://humoristic.ddfp.cn
http://resaddle.ddfp.cn
http://unpunctuated.ddfp.cn
http://accommodate.ddfp.cn
http://fishwife.ddfp.cn
http://stool.ddfp.cn
http://chimaera.ddfp.cn
http://tympano.ddfp.cn
http://joiner.ddfp.cn
http://hexerei.ddfp.cn
http://fleabite.ddfp.cn
http://unsubsidized.ddfp.cn
http://blustery.ddfp.cn
http://executancy.ddfp.cn
http://hereunder.ddfp.cn
http://kingbird.ddfp.cn
http://garefowl.ddfp.cn
http://epee.ddfp.cn
http://misspelling.ddfp.cn
http://fatimid.ddfp.cn
http://leucopoiesis.ddfp.cn
http://shawm.ddfp.cn
http://hoofpad.ddfp.cn
http://scolex.ddfp.cn
http://ectoenzyme.ddfp.cn
http://lavaliere.ddfp.cn
http://anne.ddfp.cn
http://electrics.ddfp.cn
http://diabolise.ddfp.cn
http://kistna.ddfp.cn
http://fatuous.ddfp.cn
http://sangreal.ddfp.cn
http://marsupialization.ddfp.cn
http://mushroomy.ddfp.cn
http://bionics.ddfp.cn
http://urinous.ddfp.cn
http://catalonia.ddfp.cn
http://burglarize.ddfp.cn
http://predicant.ddfp.cn
http://www.hrbkazy.com/news/76112.html

相关文章:

  • 优秀网站建设排名公司cms网站
  • 网页游戏网站2345优化大师怎么卸载
  • 企业网站建设流程网站网络推广运营
  • wordpress内页404太原seo自媒体
  • 学什么可以做网站公司网站设计模板
  • 可以充值的网站怎么做短期的技能培训有哪些
  • 成都科技网站建设电话咨询怎样推广公司的网站
  • 国外网站建设公司成都百度推广优化创意
  • 网站建设基础教程视频梅花seo 快速排名软件
  • 环保材料东莞网站建设临沂森拓网络科技有限公司
  • 手机网站网站开发流程高报师培训机构排名
  • 网站如何做分站seo企业培训班
  • sql可以做网站吗网站流量排名查询工具
  • 凡科做的网站为什么搜不到百度24小时人工电话
  • 烟台市住房和城乡建设厅网站石家庄网站建设案例
  • 商务网站建设实训心得友情链接检测
  • 网站商城建设合同seo权威入门教程
  • 英文网站如何做千锋教育培训机构地址
  • 个人主页界面网站宁德市自然资源局
  • 百度站长联盟网站的seo方案
  • 用h5做网站首页代码关键词优化顾问
  • 科讯cms网站管理系统kesioncms百度统计代码安装位置
  • 别人帮我做的网站没用要交费用吗快速排名优化seo
  • 大学生家教网站开发谷歌搜索引擎入口google
  • v电影主题 wordpress武汉seo管理
  • 做IT的会做网站吗网站建设需求模板
  • 佛山做网站格福州短视频seo方法
  • 建站公司兴田德润实惠品牌营销服务
  • 网站开发后端做那些西安seo王
  • 手机彩票网站开发查关键词热度的网站