您的位置:首页 > 健康 > 养生 > 20240624每日后端----------是时候升级springboot到springCloudAlibaba了

20240624每日后端----------是时候升级springboot到springCloudAlibaba了

2024/7/6 21:12:33 来源:https://blog.csdn.net/weixin_42678822/article/details/139917706  浏览:    关键词:20240624每日后端----------是时候升级springboot到springCloudAlibaba了

springboot

springboot官网

springCloudAlibaba

springCloudAlibaba官网

Spring Cloud Alibaba 定位

Spring Cloud Alibaba 是阿里巴巴结合自身丰富的微服务实践而推出的微服务开发的一站式解决方案,是 Spring Cloud 第二代实现的主要组成部分。吸收了 Spring Cloud Netflix 微服务框架的核心架构思想,并进行了高性能改进。自 Spring Cloud Netflix 进入停更维护后,Spring Cloud Alibaba 逐渐代替它成为主流的微服务框架。

同时 Spring Cloud Alibaba 也是国内首个进入 Spring 社区的开源项目。2018 年 7 月,Spring Cloud Alibaba 正式开源,并进入 Spring Cloud 孵化器中孵化;2019 年 7 月,Spring Cloud 官方宣布 Spring Cloud Alibaba 毕业,并将仓库迁移到 Alibaba Github OSS 下。
在这里插入图片描述

Spring Boot 应用升级为 Spring Cloud Alibaba

以下是应用升级 Spring Cloud Alibaba的完整步骤。
核对版本号:
在这里插入图片描述

第一步,父级pom引入依赖

在你的父级pom里面引入版本依赖,这里我引入的是最新版本

  • jdk17
  • springboot 3.2.6
  • Spring Cloud Alibaba 2023.0.1.0
<dependencyManagement><dependencies><!-- SpringCloud 微服务 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>2023.0.1</version><type>pom</type><scope>import</scope></dependency><!-- SpringCloud Alibaba 微服务 --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId><version>2023.0.1.0</version><type>pom</type><scope>import</scope></dependency></dependencies>
</dependencyManagement>

第二步,子级pom引入依赖

<!-- SpringCloud Ailibaba Nacos -->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency><!-- SpringCloud Ailibaba Nacos Config -->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

第三步,配置子级yml文件

spring:cloud:nacos:config:import-check:enabled: falsenamespace: publicserver-addr: 127.0.0.1:8848file-extension: ymlprefix: ${spring.application.name}discovery:server-addr: 127.0.0.1:8848group: DEFAULT_GROUP

第四步,启动2.3.2版本nacos

nacos下载
更改nacos配置文件bin/startup.cmd,本地启动改为单机启动 set MODE=“standalone”

在这里插入图片描述

成果如下

在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com