平台管理端基本完成
This commit is contained in:
36
guigu-ssyx-parent/service-gateway/pom.xml
Normal file
36
guigu-ssyx-parent/service-gateway/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>guigu-ssyx-parent</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>service-gateway</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.atguigu</groupId>
|
||||
<artifactId>common-util</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- 服务注册 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@@ -0,0 +1,22 @@
|
||||
package com.atguigu.ssyx;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
/**
|
||||
* ClassName: ServiceGatewayApplication
|
||||
* Package: com.atguigu.ssyx
|
||||
*
|
||||
* @author yovinchen
|
||||
* @Create 2023/9/20 16:51
|
||||
*/
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class ServiceGatewayApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ServiceGatewayApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.atguigu.ssyx.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.reactive.CorsWebFilter;
|
||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.util.pattern.PathPatternParser;
|
||||
|
||||
/**
|
||||
* ClassName: CorsConfig
|
||||
* Package: com.atguigu.ssyx.config
|
||||
*
|
||||
* @author yovinchen
|
||||
* @Create 2023/9/20 16:52
|
||||
*/
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
public CorsWebFilter corsFilter() {
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
config.addAllowedMethod("*");
|
||||
config.addAllowedOrigin("*");
|
||||
config.addAllowedHeader("*");
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsWebFilter(source);
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
server:
|
||||
port: 8200
|
||||
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
discovery:
|
||||
locator:
|
||||
enabled: true
|
||||
routes:
|
||||
- id: service-acl
|
||||
uri: lb://service-acl
|
||||
predicates:
|
||||
- Path=/*/acl/**
|
||||
|
||||
- id: service-sys
|
||||
uri: lb://service-sys
|
||||
predicates:
|
||||
- Path=/*/sys/**
|
||||
|
||||
- id: service-product
|
||||
uri: lb://service-product
|
||||
predicates:
|
||||
- Path=/*/product/**
|
||||
|
||||
- id: service-activity
|
||||
uri: lb://service-activity
|
||||
predicates:
|
||||
- Path=/*/activity/**
|
||||
|
||||
- id: service-order
|
||||
uri: lb://service-order
|
||||
predicates:
|
||||
- Path=/*/order/**
|
||||
|
||||
- id: service-payment
|
||||
uri: lb://service-payment
|
||||
predicates:
|
||||
- Path=/*/payment/**
|
||||
|
||||
- id: service-user
|
||||
uri: lb://service-user
|
||||
predicates:
|
||||
- Path=/*/user/**
|
||||
|
||||
- id: service-search
|
||||
uri: lb://service-search
|
||||
predicates:
|
||||
- Path=/*/search/**
|
||||
|
||||
- id: service-home
|
||||
uri: lb://service-home
|
||||
predicates:
|
||||
- Path=/*/home/**
|
||||
|
||||
- id: service-cart
|
||||
uri: lb://service-cart
|
||||
predicates:
|
||||
- Path=/*/cart/**
|
@@ -0,0 +1,11 @@
|
||||
spring:
|
||||
application:
|
||||
name: service-gateway
|
||||
profiles:
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 82.157.68.223:8848
|
||||
username: nacos
|
||||
password: nacos
|
Reference in New Issue
Block a user