diff --git a/README.md b/README.md
index 2b88661290824d31cbc7fa753e4c45f10434b89a..cbe051b74d12412cc6e9afc635723f585d05074e 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ whatsmars-sharding-jdbc | 开源分布式数据库中间件
whatsmars-spring | spring原理、集成及新特性
whatsmars-spring-boot | springboot实战
whatsmars-spring-boot-samples | 常用starters样例
-whatsmars-spring-cloud | springcloud demo
+whatsmars-spring-cloud | Finchley
whatsmars-tomcat | 模拟tomcat实现,embed tomcat
[spring-boot-latest](https://github.com/javahongxi/spring-boot-latest) | Spring 5+, Spring Boot 2+
[spring-boot-simple](https://github.com/javahongxi/spring-boot-simple) | the simplest boot
diff --git a/whatsmars-spring-cloud/README.md b/whatsmars-spring-cloud/README.md
index dec33fa1c99eac203fa798f3c92a7b175b6a9f9b..3221d3f6960c96d93403a2558aea6d0b1acb8248 100644
--- a/whatsmars-spring-cloud/README.md
+++ b/whatsmars-spring-cloud/README.md
@@ -1,13 +1,9 @@
-https://github.com/spring-cloud/spring-cloud-netflix
+# Spring Cloud
+`Finchley`
-依次启动eureka,provider,consumer,zuul
+依次启动eureka,provider,consumer
1. 直接访问 localhost:8763/hi?name=hongxi
-1. 网关访问 localhost:8764/demo/hi?name=hongxi&accessToken=123456 localhost:8764/demo/hi?name=hongxi
1. 停掉provider,再次进行上面的访问
-API网关(zuul)
-1. 通过 API 网关,封装微服务的 REST API。
-1. 均通过 API 网关 进行调用,享受 API 网关带来的统一鉴权,统一监控等好处。
-1. 通过 API 网关,控制对外暴露的 API,减轻安全隐患。
-
+https://github.com/spring-cloud/spring-cloud-netflix
https://github.com/spring-cloud-samples
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/pom.xml b/whatsmars-spring-cloud/pom.xml
index c822de15bc45574ef24cd9dd7942e6db95517947..9a4ec40743f2fdb2a58e69945396140a934726ff 100644
--- a/whatsmars-spring-cloud/pom.xml
+++ b/whatsmars-spring-cloud/pom.xml
@@ -3,36 +3,37 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- whatsmars-parent
- org.hongxi
- 1.0-SNAPSHOT
-
4.0.0
+ org.hongxi
whatsmars-spring-cloud
+ 1.0-SNAPSHOT
pom
${project.artifactId}
The demo module of spring cloud project
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.5.RELEASE
+
+
+
whatsmars-cloud-consumer
whatsmars-cloud-eureka
whatsmars-cloud-provider
- whatsmars-cloud-zuul
+
- Edgware.RELEASE
+ UTF-8
+ UTF-8
+ 1.8
+ Finchley.RELEASE
-
- org.springframework.boot
- spring-boot-dependencies
- ${spring-boot.version}
- pom
- import
-
org.springframework.cloud
spring-cloud-dependencies
@@ -44,6 +45,14 @@
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
spring-milestones
Spring Milestones
@@ -54,4 +63,13 @@
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-consumer/pom.xml b/whatsmars-spring-cloud/whatsmars-cloud-consumer/pom.xml
index 51d84b577907f6debe8db4572b5675671ce19efa..74960d35684d8c27b7ee63fd77839ba553e8c0cf 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-consumer/pom.xml
+++ b/whatsmars-spring-cloud/whatsmars-cloud-consumer/pom.xml
@@ -21,62 +21,21 @@
org.springframework.cloud
- spring-cloud-starter-eureka
+ spring-cloud-starter-netflix-eureka-client
org.springframework.cloud
- spring-cloud-starter-feign
+ spring-cloud-starter-openfeign
org.springframework.cloud
- spring-cloud-starter-hystrix
+ spring-cloud-starter-netflix-hystrix
-
- org.springframework.cloud
- spring-cloud-starter-ribbon
-
-
org.springframework.boot
- spring-boot-starter-test
- test
+ spring-boot-starter-webflux
-
-
- ${project.artifactId}
-
-
- src/main/resources
- true
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.springframework
- springloaded
- ${springloaded.version}
-
-
-
-
- ${start-class}
- ZIP
-
-
-
-
- repackage
-
-
-
-
-
-
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/ConsumerApplication.java b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/ConsumerApplication.java
index 253eb384a91758e222a8e00ff46f17a5eecabfeb..16e2d458f3af1d5ff35b49d528b6729982009a5b 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/ConsumerApplication.java
+++ b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/ConsumerApplication.java
@@ -4,10 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.client.loadbalancer.LoadBalanced;
-import org.springframework.cloud.netflix.feign.EnableFeignClients;
-import org.springframework.context.annotation.Bean;
-import org.springframework.web.client.RestTemplate;
+import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Created by shenhongxi on 2017/9/14.
@@ -20,10 +17,4 @@ public class ConsumerApplication {
public static void main(String[] args) {
SpringApplication.run(ConsumerApplication.class, args);
}
-
- @Bean
- @LoadBalanced
- RestTemplate restTemplate() {
- return new RestTemplate();
- }
}
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/controller/DemoController.java b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/controller/DemoController.java
index 2148aa8a5e6b1826a9b4d7f13c73d79f0041d304..5c6b53bf501299fec30a0389850c26525e3534f8 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/controller/DemoController.java
+++ b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/controller/DemoController.java
@@ -1,10 +1,10 @@
package org.hongxi.whatsmars.cloud.consumer.controller;
import org.hongxi.whatsmars.cloud.consumer.feign.DemoFeign;
-import org.hongxi.whatsmars.cloud.consumer.rpc.DemoRpc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
/**
* Created by shenhongxi on 2017/9/14.
@@ -12,19 +12,11 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class DemoController {
- @Autowired
- private DemoRpc demoRpc;
-
@Autowired
private DemoFeign demoFeign;
- @RequestMapping("/hello")
- public String hello(String name) {
- return demoRpc.hello(name);
- }
-
@RequestMapping("/hi")
- public String hi(String name) {
- return demoFeign.hello(name);
+ public Mono hi(String name) {
+ return Mono.just(demoFeign.hello(name));
}
}
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/feign/DemoFeign.java b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/feign/DemoFeign.java
index e1d2e943e64476d48285438eef81333a428d8d31..e5570b247d097da6be7e783979b915c175f05d69 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/feign/DemoFeign.java
+++ b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/feign/DemoFeign.java
@@ -1,13 +1,13 @@
package org.hongxi.whatsmars.cloud.consumer.feign;
-import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
* Created by shenhongxi on 2017/9/14.
*/
-@FeignClient(value = "${provider.name}", fallback = DemoHystrix.class)
+@FeignClient(value = "demo-provider", fallback = DemoHystrix.class)
public interface DemoFeign {
@RequestMapping("/hello")
String hello(@RequestParam(name = "name") String name); // 此处必须有RequestParam
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/rpc/DemoRpc.java b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/rpc/DemoRpc.java
deleted file mode 100644
index 9797e3b7f4f81c763fc848013a95ef316566a7ec..0000000000000000000000000000000000000000
--- a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/rpc/DemoRpc.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.hongxi.whatsmars.cloud.consumer.rpc;
-
-import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.env.Environment;
-import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * Created by javahongxi on 2017/12/28.
- */
-@Component
-public class DemoRpc {
-
- @Autowired
- private RestTemplate restTemplate;
- @Autowired
- private Environment env;
-
- @HystrixCommand(fallbackMethod = "helloFallback")
- public String hello(String name) {
- return restTemplate.getForObject("http://" + env.getProperty("provider.name") + "/hello?name=" + name, String.class);
- }
-
- public String helloFallback(String name) {
- return "Hi, " + name + ", Here is Fallback";
- }
-}
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/resources/application.yml b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/resources/application.yml
index 718eee5a027b615c00a832c5c490a60cda98c35f..694459d9563b14016e2d89f3b1be238019257444 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/resources/application.yml
+++ b/whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/resources/application.yml
@@ -1,36 +1,12 @@
-spring:
- profiles:
- active: dev
-
-provider:
- name: demo-provider
-
----
-eureka:
- client:
- serviceUrl:
- defaultZone: http://test.toutiao.im:8761/eureka/
-server:
- port: 8763
spring:
application:
name: demo-consumer
- profiles: test
-feign:
- hystrix:
- enabled: true
-
----
eureka:
client:
- serviceUrl:
+ service-url:
defaultZone: http://localhost:8761/eureka/
server:
port: 8763
-spring:
- application:
- name: demo-consumer
- profiles: dev
feign:
hystrix:
enabled: true
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-eureka/pom.xml b/whatsmars-spring-cloud/whatsmars-cloud-eureka/pom.xml
index 1f41b7692b2e8fd922d846d628534572e1cfd9ff..988f479697ff97d8be265652426b65ee33f87b46 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-eureka/pom.xml
+++ b/whatsmars-spring-cloud/whatsmars-cloud-eureka/pom.xml
@@ -19,50 +19,8 @@
org.springframework.cloud
- spring-cloud-starter-eureka-server
+ spring-cloud-starter-netflix-eureka-server
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- ${project.artifactId}
-
-
- src/main/resources
- true
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.springframework
- springloaded
- ${springloaded.version}
-
-
-
-
- ${start-class}
- ZIP
-
-
-
-
- repackage
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-eureka/src/main/resources/application.yml b/whatsmars-spring-cloud/whatsmars-cloud-eureka/src/main/resources/application.yml
index d02066276df47875dea82d07f8d2a03a906fd1c4..736a77d581fd61382b2ec4b6902a078cdbfb779c 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-eureka/src/main/resources/application.yml
+++ b/whatsmars-spring-cloud/whatsmars-cloud-eureka/src/main/resources/application.yml
@@ -1,29 +1,5 @@
-spring:
- profiles:
- active: dev
-
----
-spring:
- profiles: test
server:
port: 8761
-
-eureka:
- instance:
- hostname: test.toutiao.im
- client:
- registerWithEureka: false
- fetchRegistry: false
- serviceUrl:
-# defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
- defaultZone: http://test.toutiao.im:8761/eureka/
-
----
-spring:
- profiles: dev
-server:
- port: 8761
-
eureka:
instance:
hostname: localhost
@@ -31,4 +7,4 @@ eureka:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
- defaultZone: http://localhost:8761/eureka/
\ No newline at end of file
+ defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-provider/pom.xml b/whatsmars-spring-cloud/whatsmars-cloud-provider/pom.xml
index c449f33a55046e5430d5894fa408885fb873eec4..03903cfa42b41fdc30664ecae9cdc8682a85ce5f 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-provider/pom.xml
+++ b/whatsmars-spring-cloud/whatsmars-cloud-provider/pom.xml
@@ -19,50 +19,13 @@
org.springframework.cloud
- spring-cloud-starter-eureka
+ spring-cloud-starter-netflix-eureka-client
-
org.springframework.boot
- spring-boot-starter-test
- test
+ spring-boot-starter-webflux
-
-
- ${project.artifactId}
-
-
- src/main/resources
- true
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.springframework
- springloaded
- ${springloaded.version}
-
-
-
-
- ${start-class}
- ZIP
-
-
-
-
- repackage
-
-
-
-
-
-
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/java/org/hongxi/whatsmars/cloud/provider/ProviderApplication.java b/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/java/org/hongxi/whatsmars/cloud/provider/ProviderApplication.java
index 311dd1e06022a66630c2be3bb68911c5b2bec2b2..e270b1db30bce3f07073cf000bb1f2b269d422c6 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/java/org/hongxi/whatsmars/cloud/provider/ProviderApplication.java
+++ b/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/java/org/hongxi/whatsmars/cloud/provider/ProviderApplication.java
@@ -1,7 +1,7 @@
package org.hongxi.whatsmars.cloud.provider;
+import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
@@ -11,6 +11,6 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
public class ProviderApplication {
public static void main(String[] args) {
- new SpringApplicationBuilder(ProviderApplication.class).web(true).run(args);
+ SpringApplication.run(ProviderApplication.class, args);
}
}
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/java/org/hongxi/whatsmars/cloud/provider/service/DemoService.java b/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/java/org/hongxi/whatsmars/cloud/provider/service/DemoService.java
index b8125b661225c0fc15485b30793d7176d420b5c9..bf8bf88b6bcda0df17fa0ca2eaa1acafadc5cb5e 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/java/org/hongxi/whatsmars/cloud/provider/service/DemoService.java
+++ b/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/java/org/hongxi/whatsmars/cloud/provider/service/DemoService.java
@@ -3,6 +3,7 @@ package org.hongxi.whatsmars.cloud.provider.service;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+import reactor.core.publisher.Mono;
/**
* Created by shenhongxi on 2017/9/14.
@@ -13,7 +14,7 @@ public class DemoService {
private String port;
@RequestMapping("/hello")
- public String hello(String name) {
- return "Hi, " + name + ", Here is " + port;
+ public Mono hello(String name) {
+ return Mono.just("Hi, " + name + ", Here is " + port);
}
}
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/resources/application.yml b/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/resources/application.yml
index ac91c03fd222823b15d10b997062c4c03931d651..e4ea6f7f695e47b9921e010bf067c02e2775f95c 100644
--- a/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/resources/application.yml
+++ b/whatsmars-spring-cloud/whatsmars-cloud-provider/src/main/resources/application.yml
@@ -1,20 +1,3 @@
-spring:
- profiles:
- active: dev
-
----
-eureka:
- client:
- serviceUrl:
- defaultZone: http://test.toutiao.im:8761/eureka/
-server:
- port: 8762
-spring:
- application:
- name: demo-provider
- profiles: test
-
----
eureka:
client:
serviceUrl:
@@ -23,5 +6,4 @@ server:
port: 8762
spring:
application:
- name: demo-provider
- profiles: dev
+ name: demo-provider
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-zuul/pom.xml b/whatsmars-spring-cloud/whatsmars-cloud-zuul/pom.xml
deleted file mode 100644
index 5c81bef8c5c9e6e9fa2bf2057f98731bdc626785..0000000000000000000000000000000000000000
--- a/whatsmars-spring-cloud/whatsmars-cloud-zuul/pom.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-
-
-
- whatsmars-spring-cloud
- org.hongxi
- 1.0-SNAPSHOT
-
- 4.0.0
-
- whatsmars-cloud-zuul
- ${project.artifactId}
-
-
- org.hongxi.whatsmars.cloud.zuul.ZuulApplication
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka
-
-
- org.springframework.cloud
- spring-cloud-starter-zuul
-
-
-
- org.slf4j
- jcl-over-slf4j
-
-
- ch.qos.logback
- logback-classic
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
- ${project.artifactId}
-
-
- src/main/resources
- true
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
- org.springframework
- springloaded
- ${springloaded.version}
-
-
-
-
- ${start-class}
- ZIP
-
-
-
-
- repackage
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/ZuulApplication.java b/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/ZuulApplication.java
deleted file mode 100644
index 1ea2e8b1adcad035a397bb47070e1a5677b5531b..0000000000000000000000000000000000000000
--- a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/ZuulApplication.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.hongxi.whatsmars.cloud.zuul;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
-
-/**
- * Created by shenhongxi on 2017/12/27.
- */
-@SpringBootApplication
-@EnableZuulProxy
-public class ZuulApplication {
- public static void main(String[] args) {
- SpringApplication.run(ZuulApplication.class, args);
- }
-}
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/filter/AccessFilter.java b/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/filter/AccessFilter.java
deleted file mode 100644
index 67e5151ba5d6eb764408060af01866a5dda5ecd7..0000000000000000000000000000000000000000
--- a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/filter/AccessFilter.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.hongxi.whatsmars.cloud.zuul.filter;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.netflix.zuul.ZuulFilter;
-import com.netflix.zuul.context.RequestContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
-import org.springframework.stereotype.Component;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * Created by shenhongxi on 2017/12/27.
- */
-@Component
-public class AccessFilter extends ZuulFilter {
-
- private final Logger logger = LoggerFactory.getLogger(getClass());
-
- private static final String LOGIN_URL = "http://hongxi.org/login";
-
- @Override
- public String filterType() {
- return "pre";
- }
-
- @Override
- public int filterOrder() {
- return 0;
- }
-
- @Override
- public boolean shouldFilter() {
- return true;
- }
-
- @Override
- public Object run() {
- RequestContext ctx = RequestContext.getCurrentContext();
- HttpServletRequest request = ctx.getRequest();
- logger.info("{} request to {}", request.getMethod(), request.getRequestURL().toString());
-
- Object accessToken = request.getParameter("accessToken");
- if (accessToken == null) {
- try {
- logger.info("access token is empty");
- ReturnMessage message = new ReturnMessage(360, LOGIN_URL, "未登录");
- ctx.setSendZuulResponse(false);
- ctx.getResponse().setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
- ctx.setResponseStatusCode(HttpStatus.OK.value());
- ctx.setResponseBody(new ObjectMapper().writeValueAsString(message));
- } catch (Exception e) {
- logger.error("build response fail", e);
- }
- }
- return null;
- }
-}
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/filter/ReturnMessage.java b/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/filter/ReturnMessage.java
deleted file mode 100644
index fcc73da49e949fbada7be6b7ed30432dc9f0516e..0000000000000000000000000000000000000000
--- a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/java/org/hongxi/whatsmars/cloud/zuul/filter/ReturnMessage.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package org.hongxi.whatsmars.cloud.zuul.filter;
-
-public class ReturnMessage {
-
- private int status;
-
- private String returnUrl;
-
- private String message;
-
- public int getStatus() {
- return status;
- }
-
- public void setStatus(int status) {
- this.status = status;
- }
-
- public String getReturnUrl() {
- return returnUrl;
- }
-
- public void setReturnUrl(String returnUrl) {
- this.returnUrl = returnUrl;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public ReturnMessage(int status, String returnUrl, String message) {
- super();
- this.status = status;
- this.returnUrl = returnUrl;
- this.message = message;
- }
-
- public ReturnMessage(int status, String message) {
- super();
- this.status = status;
- this.returnUrl = null;
- this.message = message;
- }
-
- public ReturnMessage() {
- super();
- }
-
-}
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/resources/application.yml b/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/resources/application.yml
deleted file mode 100644
index d39bd4cbae5e7b0d6eb2285d196e139b92e018d2..0000000000000000000000000000000000000000
--- a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/resources/application.yml
+++ /dev/null
@@ -1,39 +0,0 @@
-spring:
- profiles:
- active: dev
-
----
-eureka:
- client:
- serviceUrl:
- defaultZone: http://test.toutiao.im:8761/eureka/
-server:
- port: 8764
-spring:
- application:
- name: demo-zuul
- profiles: test
-
----
-eureka:
- client:
- serviceUrl:
- defaultZone: http://localhost:8761/eureka/
-server:
- port: 8764
-spring:
- application:
- name: demo-zuul
- profiles: dev
-
-zuul:
- routes:
- demo:
- path: /demo/**
- serviceId: demo-consumer
- stripPrefix: true
- sensitiveHeaders: // 表示不过滤Headers,如Cookie
- demo2:
- path: /demo2/**
- serviceId: demo2-consumer
- stripPrefix: true
\ No newline at end of file
diff --git a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/resources/logback.xml b/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/resources/logback.xml
deleted file mode 100644
index e8b49285476447575cf92c46da478892d8263856..0000000000000000000000000000000000000000
--- a/whatsmars-spring-cloud/whatsmars-cloud-zuul/src/main/resources/logback.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
- ${log.context.name}
-
-
-
- ${log.pattern}
-
-
-
-
-
-
-
-