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

个人网站建设思路省级别网站建设方案

个人网站建设思路,省级别网站建设方案,建设会员网站需要多少钱,湖南长沙装修公司一、本地部署Nacos Nacos本地部署可以参考:http://www.iocoder.cn/Nacos/install/?self 二、搭建SpringCloud项目 示例代码: https://github.com/wyc192273/soul-learn-project/tree/main/sofa-demo 搭建了简单的SpringCloud服务后,需要在项目中引入如下…

一、本地部署Nacos

Nacos本地部署可以参考:http://www.iocoder.cn/Nacos/install/?self

二、搭建SpringCloud项目

示例代码: https://github.com/wyc192273/soul-learn-project/tree/main/sofa-demo

  • 搭建了简单的SpringCloud服务后,需要在项目中引入如下依赖:
<!-- 引入 Soul 针对 Spring Cloud 的集成的依赖 --><dependency><groupId>org.dromara</groupId><artifactId>soul-spring-boot-starter-client-springcloud</artifactId><version>${soul.version}</version></dependency>
  • 修改application.yaml文件,添加如下配置
soul:springcloud:admin-url: http://localhost:9095context-path: /springcloudfull: true
# adminUrl: 为你启动的soul-admin 项目的ip + 端口,注意要加http://
# contextPath: 为你的这个mvc项目在soul网关的路由前缀,这个你应该懂意思把? 比如/order ,/product 等等,网关会根据你的这个前缀来进行路由.
# full: 设置true 代表代理你的整个服务,false表示代理你其中某几个controller
  • 在实现类上添加@SoulSpringCloudClient注解
@GetMapping("/get")
@SoulSpringCloudClient(path = "/user/get", desc = "获得用户详细")
public String getUser(@RequestParam("id") Integer id) {return "DEMO:" + id;
}
  • 设置SpringCloud插件

    需要设置soul的SpringCloud插件为开启状态,访问http://localhost:9095/#/system/plugin

    image.png
  • 启动项目,去http://localhost:9095/#/plug/springCloud看,发现注册成功了

    image.png

二、网关接入SpringCloud

在网关项目中pom引入如下依赖:

                <!--soul springCloud plugin start--><dependency><groupId>org.dromara</groupId><artifactId>soul-spring-boot-starter-plugin-springcloud</artifactId><version>${last.version}</version></dependency><dependency><groupId>org.dromara</groupId><artifactId>soul-spring-boot-starter-plugin-httpclient</artifactId><version>${last.version}</version></dependency><!--soul springCloud plugin end--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-commons</artifactId><version>2.2.0.RELEASE</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-ribbon</artifactId><version>2.2.0.RELEASE</version></dependency>
  • 如果你使用 eureka 作为 springCloud的注册中心新增如下配置:
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId><version>2.2.0.RELEASE</version></dependency>

在网关的yaml文件中 新增如下配置:

 eureka:client:serviceUrl:defaultZone: http://localhost:8761/eureka/ # 你的eureka地址instance:prefer-ip-address: true
  • 如果你使用 nacos 作为 springCloud的注册中心新增如下配置:
 <dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2.2.0.RELEASE</version></dependency>

在网关的yaml文件中 新增如下配置:

 spring:cloud:nacos:discovery:server-addr: 127.0.0.1:8848 # 你的nacos地址

重启网关

三、调用SpringCloud接口

image.png
image.png

调用都成功返回



喜欢的朋友记得点赞、收藏、关注哦!!!

http://www.dtcms.com/a/402922.html

相关文章:

  • 测试自动化教程:Parasoft如何流重定向与单元测试自动化
  • 开源AI大模型、AI智能名片与S2B2C商城小程序在价值观型社群构建与运营中的价值与应用
  • 郑州 网站建设公司阿里企业邮箱收费标准一年多少钱
  • Day03:小程序的常用操作
  • 交互的脉络:小程序事件系统详解
  • 自助建站免费平台深圳建设管理中心网站首页
  • LVS虚拟调度器学习
  • 【LVS入门宝典】LVS-TUN模式原理与配置:跨越网络界限的负载均衡解决方案
  • 【LVS入门宝典】LVS-TUN模式配置实战以及配置关键点:Real Server的路由表调整、ipip模块加载
  • LVS、Nginx、HAProxy 的区别
  • 是什么让边缘电脑真正工业化?
  • html5手机网站开发环境怎样建设淘宝客导购网站
  • 国检集团官网UI设计展示——专业界面设计实力呈现
  • 【双光相机配准】红外-可见光双光相机的坐标转换原理与实现
  • 图漾相机-ROS2-SDK-Ubuntu 4.X.X版本编译
  • ToF相机之flying pixel
  • 网站建设都需要什么技术人员网站版面做的很好的公司
  • 检测网站是否为WordPress鑫菲互动网站建设公司
  • 小说阅读网站建设微网站在线制作
  • 网站内页百度不收录短视频关键词seo优化
  • SageMaker Studio 高级篇:自动化训练管道与性能优化实战
  • 海誉网站定制做美容一般在哪个网站团购比较好
  • 博山做网站公司岳阳设计网站推荐
  • node怎么做网站秦皇岛网站关键词推广
  • 电子商务网站推广怎么做专业微网站制作
  • 生物科技公司网站建设网站建设在后台哪里查看
  • 华容网站定制怎样在百度打广告
  • 钦州网站建设如何做网站策划案
  • 杭州营销网站建设平台深圳本地做网站
  • 网站域名 空间申请表wordpress 手机发博文