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

毕设做网站工作量够吗怎么建立网站卖东西

毕设做网站工作量够吗,怎么建立网站卖东西,如何做网站支付链接,公司做网站自己可以做简单的Spring Cloud应用程序使用ZooKeeper作为注册中心的示例&#xff1a; 1.新建模块&#xff1a; 2.勾选依赖&#xff1a; 3.在pom.xml文件中做出部分修改及添加Spring Cloud Zookeeper 依赖版本&#xff1a; 完整pom文件 <?xml version"1.0" encoding&q…

简单的Spring Cloud应用程序使用ZooKeeper作为注册中心的示例:
1.新建模块:
在这里插入图片描述
2.勾选依赖:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
3.在pom.xml文件中做出部分修改及添加Spring Cloud Zookeeper 依赖版本

在这里插入图片描述
完整pom文件

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.2.2</version><relativePath/> <!-- lookup parent from repository --></parent><!-- Generated by https://start.springboot.io --><!-- 优质的 spring/boot/data/security/cloud 框架中文文档尽在 => https://springdoc.cn --><groupId>com.example</groupId><artifactId>ZooKeeper</artifactId><version>0.0.1-SNAPSHOT</version><name>ZooKeeper</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version><zookeeper.version>2.2.5.RELEASE</zookeeper.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-webflux</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-zookeeper-config</artifactId><version>${zookeeper.version}</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-zookeeper-discovery</artifactId><version>${zookeeper.version}</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>io.projectreactor</groupId><artifactId>reactor-test</artifactId><scope>test</scope></dependency></dependencies><dependencyManagement><dependencies></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

4.配置ZooKeeper连接:在application.yml文件中配置ZooKeeper的连接字符串。

spring:application:name: productcloud:zookeeper:connect-string: localhost:2181
server:port: 8101

5.新增Controller:

package com.example.zookeeperserver;import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
@RequestMapping
public class ProductController {@GetMapping("product")public String product(){return "this is product";}
}
package com.example.zookeeper;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;import java.util.List;@RestController
public class ServiceController {@Autowiredprivate DiscoveryClient discoveryClient;/*** @Description:通过注入DiscoveryClient实例来获取服务实例的信息* @Author: * @Date: 2024/2/7 15:46* @return: java.util.List<java.lang.String>*     访问地址:http://localhost:8101/services**/@GetMapping("/services")public List<String> getServices(){//返回所有注册到服务发现中心的服务名称return discoveryClient.getServices();}/*** @Description:* @Author: * @Date: 2024/2/7 15:52* @param serviceName:* @return: java.util.List<org.springframework.cloud.client.ServiceInstance>*     访问地址:http://localhost:8101/serviceInstances/product**/@GetMapping("/serviceInstances/{serviceName}")public List<ServiceInstance> getServiceInstance(@PathVariable String serviceName){//getServiceInstances方法接受一个服务名称作为参数,返回该服务的所有实例。//每个ServiceInstance对象包含了服务实例的详细信息,如主机名、端口号等return discoveryClient.getInstances(serviceName);}}

6.启动本地的服务端:
在这里插入图片描述
7.启动服务注册和发现:在主应用类中,通过@EnableDiscoveryClient注解启用服务注册和发现
在这里插入图片描述

8.访问:localhost:8101/product
在这里插入图片描述
完整项目代码

http://www.zhongyajixie.com/news/37604.html

相关文章:

  • 网站免费优化软件免费收录网站
  • 长春网站制作培训网络营销中的seo是指
  • 凡科h5尺寸南京百度关键字优化价格
  • 做外贸生意上哪个网站优化新十条
  • 0511网站昆山网站建设
  • 怎么找人做淘宝网站吗武汉千锋教育培训机构怎么样
  • 做色情网站需要多少钱郑州网站运营专业乐云seo
  • 做一款推荐类的网站常用的搜索引擎有
  • 开发公司工程部经理岗位职责北京seo网站优化公司
  • 响应式网站滑动线上推广哪个平台最好
  • 360建筑网骗子大连百度seo
  • 深圳便宜建网站提升seo排名平台
  • 指定词整站优化怎样在百度上免费建网站
  • 广州网页搜索排名提升湖南正规seo优化报价
  • 济南营销型网站制作爱站网seo综合查询
  • 爱旅游网站制作seo学校培训课程
  • 网络品牌推广是什么意思网络优化工程师证书
  • 长春网站策划宁波seo企业推广
  • 模板网站建设价位合肥seo排名扣费
  • 网站建设找哪个平台安徽百度推广怎么做
  • 任县网站建设网络公司社群运营
  • 济宁网站建设优化户外广告
  • 网站栏目设计规划表官方百度app下载
  • 怎么做静态网站百度seo关键词排名价格
  • 网站建设基本内容推广的软件
  • 网站建设学费多少钱如何做优化排名
  • 南通网站制作系统网络工具
  • 怎么做淘宝联盟网站制作文山seo
  • 找人做企业网站注意啥整合营销活动策划方案
  • 建立自己的个人网站网络营销平台名词解释