共有 10 个文件被更改,包括 192 次插入 和 4 次删除
@ -0,0 +1,27 @@ |
|||||
|
.gradle |
||||
|
/build/ |
||||
|
!gradle/wrapper/gradle-wrapper.jar |
||||
|
|
||||
|
### STS ### |
||||
|
.apt_generated |
||||
|
.classpath |
||||
|
.factorypath |
||||
|
.project |
||||
|
.settings |
||||
|
.springBeans |
||||
|
.sts4-cache |
||||
|
|
||||
|
### IntelliJ IDEA ### |
||||
|
.idea |
||||
|
*.iws |
||||
|
*.iml |
||||
|
*.ipr |
||||
|
/out/ |
||||
|
|
||||
|
### NetBeans ### |
||||
|
/nbproject/private/ |
||||
|
/build/ |
||||
|
/nbbuild/ |
||||
|
/dist/ |
||||
|
/nbdist/ |
||||
|
/.nb-gradle/ |
@ -0,0 +1,45 @@ |
|||||
|
buildscript { |
||||
|
ext { |
||||
|
springBootVersion = '2.0.3.RELEASE' |
||||
|
} |
||||
|
repositories { |
||||
|
mavenCentral() |
||||
|
} |
||||
|
dependencies { |
||||
|
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
apply plugin: 'java' |
||||
|
apply plugin: 'eclipse' |
||||
|
apply plugin: 'org.springframework.boot' |
||||
|
apply plugin: 'io.spring.dependency-management' |
||||
|
|
||||
|
group = 'com.trgis' |
||||
|
version = '0.0.1-SNAPSHOT' |
||||
|
sourceCompatibility = 1.8 |
||||
|
|
||||
|
repositories { |
||||
|
mavenCentral() |
||||
|
} |
||||
|
|
||||
|
|
||||
|
ext { |
||||
|
springCloudVersion = 'Finchley.RELEASE' |
||||
|
} |
||||
|
|
||||
|
dependencies { |
||||
|
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client') |
||||
|
compile('org.springframework.cloud:spring-cloud-starter-config') |
||||
|
compile('org.springframework.boot:spring-boot-starter-webflux') |
||||
|
compile('org.springframework.boot:spring-boot-starter-actuator') |
||||
|
compile('org.springframework.cloud:spring-cloud-starter-openfeign') |
||||
|
compile('org.springframework.cloud:spring-cloud-starter-netflix-hystrix') |
||||
|
testCompile('org.springframework.boot:spring-boot-starter-test') |
||||
|
} |
||||
|
|
||||
|
dependencyManagement { |
||||
|
imports { |
||||
|
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" |
||||
|
} |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.trgis.sb2sc; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.boot.SpringApplication; |
||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
import org.springframework.boot.web.client.RestTemplateBuilder; |
||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
||||
|
import org.springframework.cloud.client.loadbalancer.LoadBalanced; |
||||
|
import org.springframework.context.annotation.Bean; |
||||
|
import org.springframework.web.client.RestTemplate; |
||||
|
|
||||
|
@EnableDiscoveryClient |
||||
|
@SpringBootApplication |
||||
|
public class Sb2scConsumerApplication { |
||||
|
|
||||
|
@Autowired |
||||
|
private RestTemplateBuilder builder; |
||||
|
|
||||
|
@Bean |
||||
|
@LoadBalanced |
||||
|
public RestTemplate restTemplate() { |
||||
|
return builder.build(); |
||||
|
} |
||||
|
public static void main(String[] args) { |
||||
|
SpringApplication.run(Sb2scConsumerApplication.class, args); |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.trgis.sb2sc.controller; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
import org.springframework.web.client.RestTemplate; |
||||
|
import reactor.core.publisher.Mono; |
||||
|
|
||||
|
@RestController |
||||
|
public class FeignController { |
||||
|
|
||||
|
@Autowired |
||||
|
private RestTemplate restTemplate; |
||||
|
|
||||
|
@Autowired |
||||
|
private LoadBalancerClient loadBalancerClient; |
||||
|
|
||||
|
@GetMapping("/feign/{wd}") |
||||
|
public Mono<String> sayHelloWorld(@PathVariable("wd") String parm) { |
||||
|
String res = this.restTemplate.getForObject("http://sc-provider/test/" + parm, String.class); |
||||
|
return Mono.just(res); |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.trgis.sb2sc.controller; |
||||
|
|
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
import org.springframework.web.client.RestTemplate; |
||||
|
import reactor.core.publisher.Mono; |
||||
|
|
||||
|
@RestController |
||||
|
public class RibbonController { |
||||
|
|
||||
|
@Autowired |
||||
|
private RestTemplate restTemplate; |
||||
|
|
||||
|
@Autowired |
||||
|
private LoadBalancerClient loadBalancerClient; |
||||
|
|
||||
|
@GetMapping("/ribbon/{wd}") |
||||
|
public Mono<String> sayHelloWorld(@PathVariable("wd") String parm) { |
||||
|
String res = this.restTemplate.getForObject("http://sc-provider/test/" + parm, String.class); |
||||
|
return Mono.just(res); |
||||
|
} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
eureka: |
||||
|
client: |
||||
|
service-url: |
||||
|
defaultZone: http://root:booszy@localhost:8761/eureka/ |
||||
|
instance: |
||||
|
prefer-ip-address: true |
||||
|
instance-id: ${spring.application.name}:${spring.application.instance_id:${server.port}} |
||||
|
appname: sc-consumer |
||||
|
|
||||
|
spring: |
||||
|
application: |
||||
|
name: sc-consumer |
||||
|
cloud: |
||||
|
config: |
||||
|
discovery: |
||||
|
enabled: true |
||||
|
service-id: springcloud-config-server |
||||
|
fail-fast: true |
||||
|
username: root |
||||
|
password: booszy |
||||
|
profile: csdn |
||||
|
|
@ -0,0 +1,16 @@ |
|||||
|
package com.trgis.sb2sc; |
||||
|
|
||||
|
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 Sb2scApplicationTests { |
||||
|
|
||||
|
@Test |
||||
|
public void contextLoads() { |
||||
|
} |
||||
|
|
||||
|
} |
@ -1,14 +1,15 @@ |
|||||
package com.trgis.sb2sc.controller; |
package com.trgis.sb2sc.controller; |
||||
|
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
import org.springframework.web.bind.annotation.RestController; |
import org.springframework.web.bind.annotation.RestController; |
||||
import reactor.core.publisher.Mono; |
import reactor.core.publisher.Mono; |
||||
|
|
||||
@RestController |
@RestController |
||||
public class IndexController { |
public class IndexController { |
||||
|
|
||||
@GetMapping("/helloworld") |
@GetMapping("/test/{msg}") |
||||
public Mono<String> sayHelloWorld() { |
public Mono<String> sayHelloWorld(@PathVariable("msg") String msg) { |
||||
return Mono.just("Hello World SC"); |
return Mono.just("sc-provider receive : " +msg); |
||||
} |
} |
||||
} |
} |
||||
|
@ -1,2 +1,2 @@ |
|||||
rootProject.name = 'sb2sc' |
rootProject.name = 'sb2sc' |
||||
include('sc-eureka','sc-config','sc-provider') |
include('sc-eureka','sc-config','sc-provider','sc-consumer') |
正在加载...
在新工单中引用