BAEL-169 - grouping spring-cloud modules in a multi-maven project
This commit is contained in:
+32
@@ -0,0 +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
|
||||
@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());
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.baeldung.spring.cloud.eureka.client;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
public interface GreetingController {
|
||||
@RequestMapping("/greeting")
|
||||
String greeting();
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
spring:
|
||||
application:
|
||||
name: spring-cloud-eureka-client
|
||||
|
||||
server:
|
||||
port: 0
|
||||
|
||||
eureka:
|
||||
client:
|
||||
serviceUrl:
|
||||
defaultZone: ${EUREKA_URI:http://localhost:8761/eureka}
|
||||
instance:
|
||||
preferIpAddress: true
|
||||
Reference in New Issue
Block a user