Skip to content

Commit

Permalink
set config client to api-pay, api-user
Browse files Browse the repository at this point in the history
  • Loading branch information
Logan. K committed Nov 3, 2017
1 parent 3737fba commit 798bd92
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 25 deletions.
2 changes: 2 additions & 0 deletions api-pay-service-default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config-service:
test: Hello api-pay-service
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
Expand All @@ -14,7 +16,11 @@
@RestController
@EnableDiscoveryClient
@SpringBootApplication
public class ApiPayServiceApplication {
public class ApiPayServiceApplication implements CommandLineRunner {

@Value("${config-service.test}")
private String configServiceMessage;

@Autowired
private RestTemplate restTemplate;

Expand All @@ -27,10 +33,15 @@ public String message() {
return "Hello from Api Pay service";
}

@GetMapping("/consumer")
@GetMapping("/")
public String consumer() {
String result = this.restTemplate.getForObject("http://localhost:8082/message", String.class);
String result = this.restTemplate.getForObject("http://api-user-service:8082/message", String.class);
log.info("result: {}", result);
return result;
}

@Override
public void run(final String... args) throws Exception {
log.info("config-service is working: {}", this.configServiceMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ spring:
cloud:
config:
enabled: true
name: discovery-service
name: api-pay-service
uri: http://localhost:8888


Expand Down
2 changes: 2 additions & 0 deletions api-user-service-default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config-service:
test: Hello api-user-service
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
package com.weproud.apiservice;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@EnableDiscoveryClient
@SpringBootApplication
public class ApiUserServiceApplication {
public class ApiUserServiceApplication implements CommandLineRunner {

@Value("${config-service.test}")
private String configServiceMessage;

public static void main(String[] args) {
SpringApplication.run(ApiUserServiceApplication.class, args);
Expand All @@ -19,4 +26,9 @@ public static void main(String[] args) {
public String message() {
return "Hello from Api User service";
}

@Override
public void run(final String... args) throws Exception {
log.info("config-service is working: {}", this.configServiceMessage);
}
}
9 changes: 9 additions & 0 deletions api-user-service/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
spring:
cloud:
config:
enabled: true
name: api-user-service
uri: http://localhost:8888



2 changes: 0 additions & 2 deletions config-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.cloud:spring-cloud-starter-eureka')
compile('org.springframework.cloud:spring-cloud-config-server')
compile('org.springframework.cloud:spring-cloud-starter-sleuth')
compile('org.springframework.cloud:spring-cloud-starter-zipkin')

compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
Expand Down
5 changes: 0 additions & 5 deletions config-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
spring:
application:
name: config-service
zipkin:
base-url: http://localhost:9411/
sleuth:
sampler:
percentage: 1.0
cloud:
config:
server:
Expand Down
2 changes: 0 additions & 2 deletions discovery-service-default.yml

This file was deleted.

1 change: 0 additions & 1 deletion discovery-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ ext {
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.cloud:spring-cloud-starter-eureka-server')
compile('org.springframework.cloud:spring-cloud-starter-config')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
package com.weproud.eurekaserver;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@Slf4j
@EnableEurekaServer
@SpringBootApplication
public class DiscoveryServiceApplication implements CommandLineRunner {

@Value("${config-service.test}")
private String configServiceMessage;
public class DiscoveryServiceApplication {

public static void main(String[] args) {
SpringApplication.run(DiscoveryServiceApplication.class, args);
}

@Override
public void run(final String... args) throws Exception {
log.info("config-service is working: {}", this.configServiceMessage);
}
}

0 comments on commit 798bd92

Please sign in to comment.