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

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

文件结构

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

部署过程

1、修改Maven信息
  • 打开源码后先将Maven修改为框架提供的Maven配置文件(修改后需刷新Maven)
  • 附(Maven配置源码,供参考;该项目主要采用阿里云组件库):
xml 复制代码
<?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(功能组件)四大部分,可根据需要部署使用。
3、初始化数据库
  • 将源码中doc/sq文件夹下的SQL导入本地数据库:
  • navicat中新建数据库(marscloud),字符集参考sql文件中字符集(utf8mb4):
  • 导入结果:
4、初始化nacos

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

  • 首先启动本地nacos

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

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

  • 导入结果

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

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

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

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

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

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

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

验证测试

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

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

Other 可能会出现的异常

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

Over!

相关推荐
天才奇男子4 小时前
HAProxy高级功能全解析
linux·运维·服务器·微服务·云原生
老毛肚4 小时前
MyBatis插件原理及Spring集成
java·spring·mybatis
凯子坚持 c10 小时前
C++基于微服务脚手架的视频点播系统---客户端(4)
数据库·c++·微服务
老百姓懂点AI10 小时前
[微服务] Istio流量治理:智能体来了(西南总部)AI调度官的熔断策略与AI agent指挥官的混沌工程
人工智能·微服务·istio
shuair12 小时前
redis缓存预热、缓存击穿、缓存穿透、缓存雪崩
redis·spring·缓存
计算机程序设计小李同学12 小时前
基于 Spring Boot + Vue 的龙虾专营店管理系统的设计与实现
java·spring boot·后端·spring·vue
JZC_xiaozhong13 小时前
多系统权限标准不统一?企业如何实现跨平台统一权限管控
java·大数据·微服务·数据集成与应用集成·iam系统·权限治理·统一权限管理
qq_124987075314 小时前
基于Java Web的城市花园小区维修管理系统的设计与实现(源码+论文+部署+安装)
java·开发语言·前端·spring boot·spring·毕业设计·计算机毕业设计
岁岁种桃花儿15 小时前
SpringCloud从入门到上天:Nacos做微服务注册中心
java·spring cloud·微服务
Chasmれ15 小时前
Spring Boot 1.x(基于Spring 4)中使用Java 8实现Token
java·spring boot·spring