Refactored implementation of GreetingController
This commit is contained in:
parent
16e49dd8c2
commit
cb3a7518c5
@ -1,22 +0,0 @@
|
|||||||
package com.baeldung.spring.cloud.eureka.client;
|
|
||||||
|
|
||||||
import com.netflix.discovery.EurekaClient;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Lazy;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
public class GreetingControllerImpl implements GreetingController {
|
|
||||||
@Autowired
|
|
||||||
@Lazy
|
|
||||||
private EurekaClient eurekaClient;
|
|
||||||
|
|
||||||
@Value("${spring.application.name}")
|
|
||||||
private String appName;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String greeting() {
|
|
||||||
return String.format("Hello from '%s'!", eurekaClient.getApplication(appName).getName());
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user