Forgotten file for refactoring from previous commit.

This commit is contained in:
Christian Raedel 2016-08-22 02:21:09 +02:00
parent 82f1f909e1
commit c626b9cfe2
1 changed files with 18 additions and 1 deletions

View File

@ -1,15 +1,32 @@
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.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@EnableEurekaClient
public class EurekaClientApplication {
@RestController
public class EurekaClientApplication implements GreetingController {
@Autowired
@Lazy
private EurekaClient eurekaClient;
@Value("${spring.application.name}")
private String appName;
public static void main(String[] args) {
SpringApplication.run(EurekaClientApplication.class, args);
}
@Override
public String greeting() {
return String.format("Hello from '%s'!", eurekaClient.getApplication(appName).getName());
}
}