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

相关推荐
爱淋雨的男人2 天前
网关gateway详解
gateway
kaizq2 天前
Python-Nacos电商订单分布微服系统开发
python·nacos·分布微服务·ai-ima-glm·电商订单
不吃鱼的猫7482 天前
Janus WebRTC Gateway -- 从零搭建完整指南
gateway·webrtc
zhojiew2 天前
关于AWS Direct Connect with Transit Gateway和Direct Connect Gateway
云计算·gateway·aws
亚马逊云开发者2 天前
GameLift Servers DDoS防护实战:Player Gateway + Ping Beacons延迟优化 + C++ SDK集成
c++·gateway·ddos
戮戮2 天前
Spring Cloud Gateway 零拷贝参数校验:一种高性能网关架构实践
java·网络·架构·gateway
记忆张量MemTensor2 天前
SkillsVote:从技能目录走向终极技能网关(Ultimate Skill Gateway)
gateway
w6100104664 天前
CKA-2026-Gateway
kubernetes·gateway·cka
鬼先生_sir4 天前
SpringCloud-GateWay网关
java·spring cloud·gateway
zs宝来了5 天前
Nacos 服务发现与配置中心原理:AP 架构与 Distro 协议
nacos·服务发现·配置中心·ap架构·distro协议