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

相关推荐
BothSavage1 天前
Knife4j在Gateway下的URI优化以及热刷新
windows·gateway
水w2 天前
【项目实践】SpringBoot Nacos配置管理 map数据
java·服务器·开发语言·spring boot·nacos
维李设论2 天前
Node.js的Web服务在Nacos中的实践
前端·spring cloud·微服务·eureka·nacos·node.js·express
壹佰大多2 天前
【spring-cloud-gateway总结】
java·spring·gateway
龙哥·三年风水3 天前
workman服务端开发模式-应用开发-后端api推送修改二
分布式·gateway·php
龙哥·三年风水3 天前
workman服务端开发模式-应用开发-后端api推送修改一
分布式·gateway·php
Hello Dam3 天前
面向微服务的Spring Cloud Gateway的集成解决方案:用户登录认证与访问控制
spring cloud·微服务·云原生·架构·gateway·登录验证·单点登录
小笨猪-3 天前
统⼀服务⼊⼝-Gateway
java·spring cloud·微服务·gateway
bohu833 天前
通过gateway实现服务的平滑迁移
gateway·平滑·weight
岁月变迁呀3 天前
Spring Cloud Gateway 源码
java·spring·spring cloud·gateway