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

007 SpringCloudAlibaba基础使用(nacos,gateway)

文章目录

    • cubemall-common
    • cubemall-product
    • cubemall-gateway

https://nacos.io/

https://github.com/alibaba/nacos/releases/tag/1.4.1

https://github.com/alibaba/spring-cloud-alibaba

https://github.com/alibaba/Nacos

https://developer.aliyun.com/mvn/guide

https://docs.spring.io/spring-cloud-gateway/docs/2.2.8.RELEASE/reference/html/

mvn clean install -U

nacos下载

git clone https://github.com/alibaba/nacos.git

启动服务器
Linux/Unix/Mac
启动命令(standalone代表着单机模式运行,非集群模式):

sh startup.sh -m standalone

如果使用的是ubuntu系统,或者运行脚本报错提示[[符号找不到,可尝试如下运行:

bash startup.sh -m standalone

Windows

startup.cmd -m standalone 

http://127.0.0.1:8848/nacos

cubemall-common

<dependencyManagement><dependencies><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId><version>2.1.0.RELEASE</version><type>pom</type><scope>import</scope></dependency></dependencies>
</dependencyManagement>
<!--服务注册/发现-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!--配置中心-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

cubemall-product

application.yml

spring:datasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://localhost:3306/cube_goods?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghaiusername: rootpassword: rootcloud:nacos:discovery:server-addr: 127.0.0.1:8848application:name: cubemall-product
server:port: 8081
mybatis-plus:mapper-locations: classpath:/mapper/**/*.xmlglobal-config:db-config:id-type: auto

CubemallProductApplication.java

package com.xd.cubemall.product;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;@SpringBootApplication
@EnableDiscoveryClient
public class CubemallProductApplication {public static void main(String[] args) {SpringApplication.run(CubemallProductApplication.class, args);}}

cubemall-gateway

Spring Cloud Routing->Gateway


http://www.mrgr.cn/news/5833.html

相关文章:

  • 上传PDF、DOC文件到SAP HCM系统中案例
  • 信息学奥赛初赛天天练-73-NOIP2016普及组-基础题4-枚举法、放苹果、统筹方法
  • 学习笔记第三十天
  • 点灯案例练习(基于寄存器)
  • Bigtop 从0开始(下)
  • 如何通过数据互通提升销售效率与客户满意度
  • GraphRAG + Ollama 本地部署全攻略:避坑实战指南
  • 二分类交叉熵与多分类交叉熵详解及实例计算
  • 手动修改zk类型的kafka offset
  • 推荐大模型书籍|《扩散模型从原理到实战》
  • qt的QCustomPlot绘制实时曲线图总结
  • 数据结构(6_3_1)——图的广度优先遍历
  • 关于Arrays.asList返回List无法新增和删除?
  • 浅谈Kafka(一)
  • 龙格-库塔法(Matlab实现)
  • 【Python机器学习】NLP概述——聊天机器人的自然语言流水线
  • 【vue3|第25期】Vue3中的useRoute:轻松访问路由信息
  • Baumer工业相机堡盟工业相机如何通过BGAPISDK初始化时过滤其它非Baumer相机(C++)
  • 实时手势识别(2)- 基于关键点分类实现零样本图片的任意手势的识别
  • 大数据面试-Zookeeper