-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4d35243
commit 67e9f5b
Showing
21 changed files
with
58 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 3 additions & 11 deletions
14
...consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/controller/DemoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
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. | ||
*/ | ||
@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<String> hi(String name) { | ||
return Mono.just(demoFeign.hello(name)); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...ars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/feign/DemoFeign.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
...atsmars-cloud-consumer/src/main/java/org/hongxi/whatsmars/cloud/consumer/rpc/DemoRpc.java
This file was deleted.
Oops, something went wrong.
26 changes: 1 addition & 25 deletions
26
whatsmars-spring-cloud/whatsmars-cloud-consumer/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.