diff --git a/spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service/src/main/java/com/tencent/cloud/polaris/discovery/service/callee/DiscoveryCalleeController.java b/spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service/src/main/java/com/tencent/cloud/polaris/discovery/service/callee/DiscoveryCalleeController.java index 7c4d82171..5bf14f949 100644 --- a/spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service/src/main/java/com/tencent/cloud/polaris/discovery/service/callee/DiscoveryCalleeController.java +++ b/spring-cloud-tencent-examples/polaris-discovery-example/discovery-callee-service/src/main/java/com/tencent/cloud/polaris/discovery/service/callee/DiscoveryCalleeController.java @@ -19,7 +19,6 @@ package com.tencent.cloud.polaris.discovery.service.callee; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -35,30 +34,35 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/discovery/service/callee") public class DiscoveryCalleeController { - private static Logger LOG = LoggerFactory.getLogger(DiscoveryCalleeController.class); + private static final Logger LOG = LoggerFactory.getLogger(DiscoveryCalleeController.class); @Value("${server.port:0}") private int port; + @Value("${spring.cloud.client.ip-address:127.0.0.1}") + private String ip; + /** * Get information of callee. + * * @return information of callee */ @GetMapping("/info") public String info() { - LOG.info("Discovery Service Callee [{}] is called.", port); - return String.format("Discovery Service Callee [%s] is called.", port); + LOG.info("Discovery Service Callee [{}:{}] is called.", ip, port); + return String.format("Discovery Service Callee [%s:%s] is called.", ip, port); } /** * Get sum of two value. + * * @param value1 value 1 * @param value2 value 2 * @return sum */ @GetMapping("/sum") public int sum(@RequestParam int value1, @RequestParam int value2) { - LOG.info("Discovery Service Callee is called and sum is {}.", value1 + value2); + LOG.info("Discovery Service Callee [{}:{}] is called and sum is {}.", ip, port, value1 + value2); return value1 + value2; } }