Skip to content

Commit c626b9c

Browse files
Forgotten file for refactoring from previous commit.
1 parent 82f1f90 commit c626b9c

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
package com.baeldung.spring.cloud.eureka.client;
22

3+
import com.netflix.discovery.EurekaClient;
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.beans.factory.annotation.Value;
36
import org.springframework.boot.SpringApplication;
47
import org.springframework.boot.autoconfigure.SpringBootApplication;
58
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
9+
import org.springframework.context.annotation.Lazy;
610
import org.springframework.web.bind.annotation.RequestMapping;
711
import org.springframework.web.bind.annotation.RestController;
812

913
@SpringBootApplication
1014
@EnableEurekaClient
11-
public class EurekaClientApplication {
15+
@RestController
16+
public class EurekaClientApplication implements GreetingController {
17+
@Autowired
18+
@Lazy
19+
private EurekaClient eurekaClient;
20+
21+
@Value("${spring.application.name}")
22+
private String appName;
23+
1224
public static void main(String[] args) {
1325
SpringApplication.run(EurekaClientApplication.class, args);
1426
}
27+
28+
@Override
29+
public String greeting() {
30+
return String.format("Hello from '%s'!", eurekaClient.getApplication(appName).getName());
31+
}
1532
}

0 commit comments

Comments
 (0)