| first-service.java
1. application.yml
server:
port: 8082
spring:
application:
name: my-second-service
eureka:
client:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: http://localhost:8761/eureka
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
2. SecondServiceController.java
@RestController
@Slf4j
@RequestMapping("/second-service")
public class SecondServiceController {
@GetMapping("/welcome")
public String welcome() {
return "Welcome to the Second service";
}
@GetMapping("/message")
public String message(@RequestHeader("second-request") String header) {
log.info(header);
return "Hello World in Second Service";
}
@GetMapping("/check")
public String check() {
return "Hi there. This is a message from Second Service.";
}
}
| second-service.java
1. application.yml
server:
port: 8082
spring:
application:
name: my-second-service
eureka:
client:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: http://localhost:8761/eureka
2. SecondServiceController.java
@RestController
@Slf4j
@RequestMapping("/second-service")
public class SecondServiceController {
@GetMapping("/welcome")
public String welcome() {
return "Welcome to the Second service";
}
@GetMapping("/message")
public String message(@RequestHeader("second-request") String header) {
log.info(header);
return "Hello World in Second Service";
}
@GetMapping("/check")
public String check() {
return "Hi there. This is a message from Second Service.";
}
}