添加SpringCloud Zuul网关支持
This commit is contained in:
@@ -18,6 +18,7 @@ eureka:
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
defaultZone: http://localhost:8001/eureka/
|
||||
registry-fetch-interval-seconds: 10
|
||||
management: #开启SpringBoot Admin的监控
|
||||
endpoints:
|
||||
web:
|
||||
|
||||
@@ -4,7 +4,7 @@ spring:
|
||||
application:
|
||||
name: mall-admin
|
||||
server:
|
||||
port: 8080
|
||||
port: 8180
|
||||
mybatis:
|
||||
mapper-locations:
|
||||
- classpath:dao/*.xml
|
||||
|
||||
31
mall-gateway/.gitignore
vendored
Normal file
31
mall-gateway/.gitignore
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**
|
||||
!**/src/test/**
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
37
mall-gateway/pom.xml
Normal file
37
mall-gateway/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-gateway</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>mall-gateway</name>
|
||||
<description>mall-gateway project for mall</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.macro.mall;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
|
||||
|
||||
@EnableZuulProxy
|
||||
@EnableDiscoveryClient
|
||||
@SpringBootApplication
|
||||
public class MallGatewayApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MallGatewayApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
23
mall-gateway/src/main/resources/application.yml
Normal file
23
mall-gateway/src/main/resources/application.yml
Normal file
@@ -0,0 +1,23 @@
|
||||
server:
|
||||
port: 8201
|
||||
spring:
|
||||
application:
|
||||
name: mall-gateway
|
||||
eureka:
|
||||
client:
|
||||
register-with-eureka: true
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
defaultZone: http://localhost:8001/eureka/
|
||||
registry-fetch-interval-seconds: 10
|
||||
zuul:
|
||||
sensitive-headers: #默认会过滤Cookie,Set-Cookie,Authorization,配置为空不过滤
|
||||
add-host-header: true #设置为true重定向是会添加host请求头
|
||||
management: #开启SpringBoot Admin的监控
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: '*'
|
||||
endpoint:
|
||||
health:
|
||||
show-details: always
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.macro.mall;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class MallGatewayApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user