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

【SpringCloud】微服务框架后端部署详细过程记录20240119

前言:前两天公司接到客户提供的一个微服务框架,导师让我在本地部署验证一下该框架的可用性,借此机会记录一下微服务项目的一个基本部署流程,仅供学习参考,如有不足还请指正!

文件结构

提供的压缩文件共包含源码、Maven配置信息以及一份框架说明

image-20240119102558275

部署过程

1、修改Maven信息
  • 打开源码后先将Maven修改为框架提供的Maven配置文件(修改后需刷新Maven)

image-20240119103027036

  • 附(Maven配置源码,供参考;该项目主要采用阿里云组件库):
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"><mirrors><mirror><id>mirror</id><mirrorOf>central,jcenter,!rdc-releases,!rdc-snapshots</mirrorOf><name>mirror</name><url>https://maven.aliyun.com/nexus/content/groups/public</url></mirror></mirrors><servers><server><id>rdc-releases</id><username>64423e0f253e98e0c616d548</username><password>cFMOPZMySW7I</password></server><server><id>rdc-snapshots</id><username>64423e0f253e98e0c616d548</username><password>cFMOPZMySW7I</password></server></servers><profiles><profile><id>rdc</id><properties><altReleaseDeploymentRepository>rdc-releases::default::https://packages.aliyun.com/maven/repository/2260349-release-dYnJeL/</altReleaseDeploymentRepository><altSnapshotDeploymentRepository>rdc-snapshots::default::https://packages.aliyun.com/maven/repository/2260349-snapshot-x4T8Ra/</altSnapshotDeploymentRepository></properties><repositories><repository><id>central</id><url>https://maven.aliyun.com/nexus/content/groups/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository><repository><id>snapshots</id><url>https://maven.aliyun.com/nexus/content/groups/public</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository><repository><id>rdc-releases</id><url>https://packages.aliyun.com/maven/repository/2260349-release-dYnJeL/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository><repository><id>rdc-snapshots</id><url>https://packages.aliyun.com/maven/repository/2260349-snapshot-x4T8Ra/</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>central</id><url>https://maven.aliyun.com/nexus/content/groups/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository><pluginRepository><id>snapshots</id><url>https://maven.aliyun.com/nexus/content/groups/public</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository><pluginRepository><id>rdc-releases</id><url>https://packages.aliyun.com/maven/repository/2260349-release-dYnJeL/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository><pluginRepository><id>rdc-snapshots</id><url>https://packages.aliyun.com/maven/repository/2260349-snapshot-x4T8Ra/</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles><activeProfiles><activeProfile>rdc</activeProfile></activeProfiles>
</settings>
2、框架结构
  • 该框架主要包括gateway(网关)、uaa(认证系统)、platform(基础平台)、plugin(功能组件)四大部分,可根据需要部署使用。

image-20240119103502143

3、初始化数据库
  • 将源码中doc/sq文件夹下的SQL导入本地数据库:

image-20240119103816394

  • navicat中新建数据库(marscloud),字符集参考sql文件中字符集(utf8mb4):

image-20240119104051330

  • 导入结果:

image-20240119104157772

4、初始化nacos

nacos 配置文件在:doc/nacos 目录下,在 nacos 控制台导入目录下的 yaml 文件

  • 首先启动本地nacosimage-20240119104644340

  • 在nacos新建命名空间(marscloud)

    image-20240119104838665

  • 导入yaml文件(可以现将所有yaml文件压缩为zip然后再导入)image-20240119105052509

  • 导入结果

    image-20240119105140265

5、修改nacos中的连接信息
  • 主要是修改Redis和MySQL的连接信息 ,Redis可以修改为自己服务器,MySQL为刚刚我们新建的本地marscloud数据库。(修改后记得发布【手动狗头】)

    image-20240119105526873

    image-20240119105620230

6、修改项目中nacos的连接信息
  • 通常情况下nacos连接信息在项目的bootstrap.yml文件夹中,但该框架无bootstrap.yml文件,而是配置项目启动的环境变量;每个微服务模块启动的环境变量都需要修改,以下为idea中的操作。

    image-20240119110428556

    启动时的环境变量如下(其中 NACOS_GROUP,NACOS_NAMESPACE 表示配置所在的组和命名空间,NACOS_URL 表示 nacos 连接地址,根据实际连接信息替换):

    Active profiles 为当前使用的配置环境

    NACOS_GROUP=DEFAULT_GROUP;NACOS_NAMESPACE=marscloud;NACOS_URL=localhost:8848

    image-20240119111616621

完成以上步骤后即可正常启动
Other 可能会出现的异常

若启动报错如下,说明未连接到nacos,需检查启动时的环境变量。

image-20240119112059566

验证测试

  • 根据以上操作启动gateway、system、uaa三个模块image-20240119113104350

  • 使用apifox获取图片验证码进行测试,正常获取验证码,即项目后端部署完成(10002为网关端口)

image-20240119114354302

Other 可能会出现的异常

若接口请求测试时出现以下异常,则可能是jdk版本导致,将jdk版本切换为1.8即可

image-20240119114622369

Over!

http://www.lryc.cn/news/285017.html

相关文章:

  • 《设计模式的艺术》笔记 - 桥接模式
  • Redis高并发分布式锁
  • 组件开发遇到的问题(vue的问题)
  • vue3前端开发,感受一下组合式api和VUE2选项式的差异
  • 电梯调度问题文献阅读
  • 文心一言 VS 讯飞星火 VS chatgpt (183)-- 算法导论13.4 7题
  • ChatGLM vs ChatGPT
  • leetcode热题100.三数之和
  • GitLab服务器忘记root密码处理方式
  • js-cookie的使用--token的数据实现持久化
  • 【实战】SpringBoot自定义 starter及使用
  • 网络爬虫采集工具
  • 【协议】XMLHttpRequest的梳理和总结
  • AI教我学编程之C#类的基本概念(1)
  • 前端js 数据结构:对象 object、数组Array 、Map 的创建、增删改 / 遍历数据
  • ARM_Linux的NFS网络文件系统的搭建
  • vscode配置web开发环境(WampServer)
  • 00-Rust前言
  • 3.conda的使用
  • IPv6自动隧道---6to4中继
  • 低代码开发:解锁数字化转型新维度
  • 写一个定时备份数据库的脚本,且只保留最近3天
  • java常见面试题:请详细解释如何在Java EE应用中添加EJB
  • 视频监控需求记录
  • Self-RAG:通过自我反思学习检索、生成和批判
  • C++基于多态的职工管理系统(附代码下载)
  • Java安全 CC链1分析
  • Miracast手机高清投屏到电视(免费)
  • 【elementUI】el-select相关问题
  • 【蓝桥杯日记】复盘第一篇——顺序结构