BAEL-169 - grouping spring-cloud modules in a multi-maven project

This commit is contained in:
slavisa-baeldung
2016-09-01 13:54:53 +02:00
parent 455d10eeff
commit a0ef91fc92
51 changed files with 1228 additions and 11 deletions
@@ -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!";
}
}
}
@@ -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";
}
}
@@ -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);
}
}
@@ -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>