Phase 1 #17: Spring Cloud Alibaba 微服务框架搭建
- Maven 父工程 wm-parent (Spring Boot 3.3.5 + Cloud 2023.0.3 + Alibaba 2023.0.1) - 12个子模块: wm-common/gateway/base/iot/data-engine/bpm/production/revenue/patrol/bi/notify/job - wm-common: 统一响应 R<T> + 全局异常处理 + BusinessException - wm-gateway: Spring Cloud Gateway 路由配置(7个微服务路由) - 集成: Nacos(注册/配置) + PostgreSQL + Redis + Kafka + Sa-Token + MyBatis-Plus + Knife4j - docker-compose.yml: 一键启动10个中间件(PG+PostGIS/TDengine/Redis/Kafka/EMQX/Nacos/ES/Kibana/MinIO/GeoServer)
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent><groupId>com.water</groupId><artifactId>wm-parent</artifactId><version>1.0.0-SNAPSHOT</version></parent>
|
||||
<artifactId>wm-gateway</artifactId>
|
||||
<dependencies>
|
||||
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId></dependency>
|
||||
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency>
|
||||
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId></dependency>
|
||||
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId></dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.water.gateway;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class GatewayApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GatewayApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: wm-gateway
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: ${NACOS_HOST:127.0.0.1}:8848
|
||||
config:
|
||||
server-addr: ${NACOS_HOST:127.0.0.1}:8848
|
||||
gateway:
|
||||
discovery:
|
||||
locator:
|
||||
enabled: true
|
||||
lower-case-service-id: true
|
||||
routes:
|
||||
- id: wm-base
|
||||
uri: lb://wm-base
|
||||
predicates:
|
||||
- Path=/api/base/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: wm-iot
|
||||
uri: lb://wm-iot
|
||||
predicates:
|
||||
- Path=/api/iot/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: wm-production
|
||||
uri: lb://wm-production
|
||||
predicates:
|
||||
- Path=/api/production/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: wm-revenue
|
||||
uri: lb://wm-revenue
|
||||
predicates:
|
||||
- Path=/api/revenue/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: wm-patrol
|
||||
uri: lb://wm-patrol
|
||||
predicates:
|
||||
- Path=/api/patrol/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: wm-bi
|
||||
uri: lb://wm-bi
|
||||
predicates:
|
||||
- Path=/api/bi/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
Reference in New Issue
Block a user