Spring Cloud Gateway mit Eureka Discovery Locator - 404Java

Java-Forum
Anonymous
 Spring Cloud Gateway mit Eureka Discovery Locator - 404

Post by Anonymous »

Ich richte eine microservices -basierte Anwendung mit Spring Cloud Gateway mit dem Eureka Discovery -Client ein. spring.cloud.gateway.discovery.locator.lower-case-service-id in der gateway application.yml-Datei. Endpunkte, die vom Gateway ausgesetzt sind, und es gibt einen Eintrag für den Dienst. < /p>
Was bin ich fehlt?

Code: Select all

spring:
application:
name: registry
server:
port: 8081

eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:${server.port}/eureka/
instance:
hostname: localhost
prefer-ip-address: true
< /code>
 Spring Cloud Gateway Application.yml < /h1>
spring:
application:
name: api-gateway
cloud:
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
main:
web-application-type: reactive

server:
port: 8080

eureka:
client:
service-url:
defaultZone: http://localhost:8081/eureka/
fetch-registry: true
register-with-eureka: true
instance:
hostname: localhost
prefer-ip-address: true

management:
endpoint:
gateway:
enabled: true
endpoints:
web:
exposure:
include:
- "*"
< /code>
 service application.yml < /h1>
server:
port: 8082

spring:
application:
name: event

eureka:
client:
service-url:
defaultZone: http://localhost:8081/eureka/
fetch-registry: true
register-with-eureka: true
instance:
hostname: localhost
prefer-ip-address: true
< /code>
Ich habe die erforderlichen Anmerkungen sowohl in Eureka Server Application als auch in Event Service Application -Klassen aufgenommen. Ich erhalte die folgende Antwort bei der Abfrage http: // localhost: 8080/Aktuator/Gateway/Routen: 
[{"predicate":"Paths: [/api-gateway/**], match trailing slash: true","metadata":{"jmx.port":"55939","management.port":"8080"},"route_id":"ReactiveCompositeDiscoveryClient_API-GATEWAY","filters":["[[RewritePath /api-gateway/?(?.*) = '/${remaining}'], order = 1]"],"uri":"lb://API-GATEWAY","order":0},{"predicate":"Paths: [/event/**], match trailing slash: true","metadata":{"jmx.port":"55880","management.port":"8082"},"route_id":"ReactiveCompositeDiscoveryClient_EVENT","filters":["[[RewritePath /event/?(?.*) = '/${remaining}'], order = 1]"],"uri":"lb://EVENT","order":0}]
< /code>
 eventController < /h1>
package example.event.endpoint.controller;

import static org.springframework.http.HttpStatus.OK;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import example.event.endpoint.service.EventService;
import example.core.model.Event;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/v1/event")
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class EventController {
private final EventService eventService;

@GetMapping
public ResponseEntity listAll(Pageable pageable) {
log.info("Retrieving all events");
return new ResponseEntity(eventService.list(pageable), OK);
}
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post