Очень новое для весеннего облака.
Внедрение Spring Cloud Feign и проблемы. Сервер Eureka запущен и работает, и на нем регистрируются следующие службы.
ПриветствиеApp
application.properties
server.port= 14000
server.context-path= /greetservices
spring.application.name=GreetingApp
management.endpoints.web.exposure.include=*
eureka.client.serviceUrl.defaultZone=${EUREKA_URI:http://localhost:8761/eureka}
Основной класс
@SpringBootApplication
@EnableEurekaClient
public class GreetingappApplication {
public static void main(String[] args) {
SpringApplication.run(GreetingappApplication.class, args);
}
}
Контроллер
@RestController
@RequestMapping("/greeting")
public class GreetingController {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
Environment environment;
@GetMapping(value = "/user")
public String greetUser() {
logger.debug(" **** In greetUser(): Server Port " + environment.getProperty("local.server.port"));
return "Hello " + "Abdul";
}
}
Я могу получить доступ к этому приложению в обычном режиме.
Клиентское приложение Feign
приложение.свойства
server.port= 15000
server.context-path= /gaconsumerservice
management.endpoints.web.exposure.include=*
spring.application.name=GreetingAppFeignConsumer
eureka.client.serviceUrl.defaultZone=${EUREKA_URI:http://localhost:8761/eureka}
eureak.client.registerWithEureka=false
eureak.client.fetchRegistry=false
Основной класс
@SpringBootApplication
@EnableCircuitBreaker
@EnableHystrixDashboard
@EnableFeignClients
@EnableEurekaClient
public class GreetingappconsumerApplication {
public static void main(String[] args) {
SpringApplication.run(GreetingappconsumerApplication.class, args);
}
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
Интерфейс клиента Feign
@FeignClient(name = "GreetingApp")
public interface GAConsumerService {
@RequestMapping(value = "/greeting/user", method = RequestMethod.GET)
public String greetUser();
}
Контроллер
@RestController
@RequestMapping("/greeting")
public class GAConsumerController {
Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
GAConsumerService gaConsumerService;
@GetMapping(value = "/user")
public String greetUser() {
logger.debug(" *** In /feign/gaconsumer::greetUser()");
return gaConsumerService.greetUser();
}
}
После всего этого, когда я пытаюсь получить доступ к приведенному ниже URL-адресу, его исключение ниже
Успех: http://localhost:14000/greetservices/greeting/user а>
Исключение: http://localhost:15000/gaconsumerservice/greeting/user а>
2019-07-24 16:25:42,109 INFO [http-nio-15000-exec-3]
com.netflix.config.ChainedDynamicProperty$ChainLink: Flipping property: GreetingApp.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-07-24 16:25:42,117 INFO [http-nio-15000-exec-3]
com.netflix.loadbalancer.DynamicServerListLoadBalancer: DynamicServerListLoadBalancer for client GreetingApp initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=GreetingApp,current list of Servers=[localhost:14000],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
},Server stats: [[Server:localhost:14000; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 05:30:00 IST 1970; First connection made: Thu Jan 01 05:30:00 IST 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]
]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@363b7066
2019-07-24 16:25:42,569 ERROR [http-nio-15000-exec-3]
org.apache.juli.logging.DirectJDKLog: Servlet.service() for servlet [dispatcherServlet] in context with path [/gaconsumerservice] threw exception [Request processing failed; nested exception is feign.FeignException: status 404 reading GAConsumerService#greetUser(); content:
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1></body></html>] with root cause
feign.FeignException: status 404 reading GAConsumerService#greetUser(); content:
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} h2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} h3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} body {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} b {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} p {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;} a {color:black;} a.name {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1></body></html>
at feign.FeignException.errorStatus(FeignException.java:62)
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91)
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:138)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:76)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
at com.sun.proxy.$Proxy95.greetUser(Unknown Source)
at org.hams.services.greetingappconsumer.controller.GAConsumerController.greetUser(GAConsumerController.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
Пожалуйста помоги.