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

相关推荐
2401_8341208710 小时前
spring-cloud-kubernetes与SpringCloud Gateway
spring cloud·kubernetes·gateway
猫头虎10 小时前
web开发常见问题解决方案大全:502/503 Bad Gateway/Connection reset/504 timed out/400 Bad Request/401 Unauthorized
运维·前端·nginx·http·https·gateway·openresty
Jinkxs10 小时前
Gateway - 内置 Filter 使用指南:AddRequestHeader、RewritePath 等实战
gateway
学习是生活的调味剂2 天前
nacos原理之服务注册浅析
java·开发语言·nacos·注册中心
利刃大大2 天前
【SpringCloud】网关GateWay && Spring Cloud Gateway && Route Predicate Factories
网关·spring·spring cloud·gateway
一个向上的运维者3 天前
基于k8s的KServe 控制平面生产级部署最佳实践:基于 Gateway API 的标准化流量管理方案
llm·gateway·istio·kserve
金刚猿4 天前
03_虚拟机中间件部署_Nacos 部署单机模式、配置鉴权
linux·中间件·nacos·配置鉴权
努力也学不会java4 天前
【Spring Cloud】统一服务入口-Gateway
后端·算法·spring·spring cloud·gateway·服务发现
利刃大大5 天前
【SpringCloud】Nacos简介 && 安装 && 快速入手 && 负载均衡
spring·spring cloud·微服务·nacos·负载均衡
dinga198510266 天前
当遇到 502 错误(Bad Gateway)怎么办
gateway