当前位置: 首页 > 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!

相关文章:

  • Unity - transform使用
  • C++核心编程
  • unity webgl 系列(2):从webgl内存中下载文件到本地硬盘
  • Baumer工业相机堡盟工业相机如何通过NEOAPI SDK使用短曝光功能(C#)
  • 有线桥接|Wifi隔了一堵墙就没信号?房间的网线口利用起来,让房间死角也有网!
  • JVM篇--垃圾回收高频面试题
  • 解决国内Linux服务器无法使用Github的方法
  • Java三大集合
  • 003-90-15【SparkSQLDFDS】慈航寺庙山脚下八卦田旁油菜花海深处人家王大爷家女儿用GPT学习DataSet的基本操作
  • 【通知】我的教学文章《Rust跟我学》已全部上线
  • 用el-image-viewer实现全局预览图片
  • STM32--7针0.96寸OLED屏幕显示(4线SPI)
  • 【已解决】Qt Creator设计模式被禁用不能点的原因及解决方案
  • Nginx重写功能location与rewrite
  • Ubuntu 22.04 安装MySql
  • [rust! #004] [译] Rust 的内置 Traits, 使用场景, 方式, 和原因
  • 【css3】浏览器内核及其兼容性
  • 【前端学习】-粗谈选择器
  • Android开发 - 掌握ConstraintLayout(四)创建基本约束
  • Android系统模拟器绘制实现概述
  • idea + plantuml 画流程图
  • Java 内存分配及垃圾回收机制初探
  • javascript 总结(常用工具类的封装)
  • JAVA多线程机制解析-volatilesynchronized
  • leetcode46 Permutation 排列组合
  • Python进阶细节
  • RxJS 实现摩斯密码(Morse) 【内附脑图】
  • SpiderData 2019年2月16日 DApp数据排行榜
  • vue-router的history模式发布配置
  • 大数据与云计算学习:数据分析(二)
  • 给初学者:JavaScript 中数组操作注意点
  • 好的网址,关于.net 4.0 ,vs 2010
  • 欢迎参加第二届中国游戏开发者大会
  • 将 Measurements 和 Units 应用到物理学
  • 通过npm或yarn自动生成vue组件
  • 吐槽Javascript系列二:数组中的splice和slice方法
  • 用 Swift 编写面向协议的视图
  • 怎么将电脑中的声音录制成WAV格式
  • NLPIR智能语义技术让大数据挖掘更简单
  • 说说我为什么看好Spring Cloud Alibaba
  • 正则表达式-基础知识Review
  • ​​​​​​​​​​​​​​Γ函数
  • ​iOS实时查看App运行日志
  • # 学号 2017-2018-20172309 《程序设计与数据结构》实验三报告
  • #{}和${}的区别是什么 -- java面试
  • $.type 怎么精确判断对象类型的 --(源码学习2)
  • (1)(1.8) MSP(MultiWii 串行协议)(4.1 版)
  • (13)Hive调优——动态分区导致的小文件问题
  • (2.2w字)前端单元测试之Jest详解篇
  • (done) 两个矩阵 “相似” 是什么意思?
  • (十二)springboot实战——SSE服务推送事件案例实现
  • (收藏)Git和Repo扫盲——如何取得Android源代码
  • (转) 深度模型优化性能 调参
  • (转)GCC在C语言中内嵌汇编 asm __volatile__
  • (转)ORM