007 SpringCloudAlibaba基础使用(nacos,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/

bash 复制代码
mvn clean install -U

nacos下载

bash 复制代码
git clone https://github.com/alibaba/nacos.git

启动服务器

Linux/Unix/Mac

启动命令(standalone代表着单机模式运行,非集群模式):

bash 复制代码
sh startup.sh -m standalone

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

bash 复制代码
bash startup.sh -m standalone

Windows

bash 复制代码
startup.cmd -m standalone 

http://127.0.0.1:8848/nacos

cubemall-common

xml 复制代码
<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>
xml 复制代码
<!--服务注册/发现-->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
xml 复制代码
<!--配置中心-->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>

cubemall-product

application.yml

yml 复制代码
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/cube_goods?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
    username: root
    password: root
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
  application:
    name: cubemall-product
server:
  port: 8081
mybatis-plus:
  mapper-locations: classpath:/mapper/**/*.xml
  global-config:
    db-config:
      id-type: auto

CubemallProductApplication.java

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

相关推荐
坐吃山猪1 天前
OpenClaw04_Gateway常见问题
网络·gateway·openclaw
三水不滴2 天前
利用SpringCloud Gateway 重试 + 降级解决第三方接口频繁超时问题,提升性能
经验分享·笔记·后端·spring·spring cloud·gateway
知识即是力量ol2 天前
微服务架构:从入门到进阶完全指南
java·spring cloud·微服务·nacos·架构·gateway·feign
j200103223 天前
Gateway—— 高级流量路由
gateway·k8s
笨蛋不要掉眼泪3 天前
Spring Cloud Gateway 核心篇:深入解析过滤器(Filter)机制与实战
java·服务器·网络·后端·微服务·gateway
笨蛋不要掉眼泪3 天前
Spring Cloud Gateway 扩展:全局跨域配置
java·分布式·微服务·架构·gateway
码农阿豪3 天前
Nacos 日志与 Raft 数据清理指南:如何安全释放磁盘空间
java·安全·nacos
love530love5 天前
ZeroClaw Reflex UI完整搭建流程——ZeroClaw Gateway + LM Studio + Reflex 本地 AI 管理面板
人工智能·windows·gateway·lm studio·reflex·openclaw·zeroclaw
利刃大大7 天前
【SpringCloud】Gateway Filter Factories && 过滤器执行顺序 && 自定义过滤器
java·后端·网关·spring cloud·gateway
2401_834120877 天前
spring-cloud-kubernetes与SpringCloud Gateway
spring cloud·kubernetes·gateway