BAEL-169 - grouping spring-cloud modules in a multi-maven project
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.spring.cloud.hystrix.rest.consumer;
|
||||
|
||||
import com.baeldung.spring.cloud.hystrix.rest.producer.GreetingController;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@FeignClient(
|
||||
name = "rest-producer",
|
||||
url = "http://localhost:9090",
|
||||
fallback = GreetingClient.GreetingClientFallback.class
|
||||
)
|
||||
public interface GreetingClient extends GreetingController {
|
||||
@Component
|
||||
public static class GreetingClientFallback implements GreetingClient {
|
||||
@Override
|
||||
public String greeting(@PathVariable("username") String username) {
|
||||
return "Hello User!";
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.spring.cloud.hystrix.rest.consumer;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
public class GreetingController {
|
||||
@Autowired
|
||||
private GreetingClient greetingClient;
|
||||
|
||||
@RequestMapping("/get-greeting/{username}")
|
||||
public String getGreeting(Model model, @PathVariable("username") String username) {
|
||||
model.addAttribute("greeting", greetingClient.greeting(username));
|
||||
return "greeting-view";
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.spring.cloud.hystrix.rest.consumer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableCircuitBreaker
|
||||
@EnableHystrixDashboard
|
||||
@EnableFeignClients
|
||||
public class RestConsumerFeignApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(RestConsumerFeignApplication.class, args);
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
server.port=8082
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Greetings from Hystrix</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2 th:text="${greeting}"/>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user