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

相关推荐
亚林瓜子7 小时前
AWS API Gateway配置日志
云计算·gateway·aws·log·cloudwatch
惊鸿一博14 小时前
java_网络服务相关_gateway_nacos_feign区别联系
java·开发语言·gateway
hanniuniu131 天前
网络安全厂商F5推出AI Gateway,化解大模型应用风险
人工智能·web安全·gateway
stormsha1 天前
Proxmox Mail Gateway安装指南:从零开始配置高效邮件过滤系统
服务器·网络·网络安全·gateway
背太阳的牧羊人2 天前
backend 服务尝试连接 qdrant 容器,但失败了,返回 502 Bad Gateway 问题排查
docker·gateway·qdrant
曼彻斯特的海边2 天前
RequestRateLimiterGatewayFilterFactory
spring cloud·gateway·限流
·云扬·2 天前
【PmHub面试篇】Gateway全局过滤器统计接口调用耗时面试要点解析
面试·职场和发展·gateway
devil_mf2 天前
gateway 网关 路由新增 (已亲测)
gateway
wmd131643067122 天前
Gateway 搭建
gateway
KubeSphere 云原生5 天前
云原生周刊:探索 Gateway API v1.3.0
云原生·gateway