Eureka Client зарегистрирован с полным именем компьютера в качестве префикса. Клиент Eureka недоступен при регистрации на сервере - PullRequest
0 голосов
/ 01 июля 2019

Я новичок в Spring Cloud.

У меня всего три приложения

Во-первых, сервер конфигурации. Во-вторых, сервер Eureka. В-третьих, служба (клиент Eureka).

  1. Сервер конфигурации успешно работает * 1008.*
  2. Eureka Server также работает нормально
  3. Моя клиентская служба Eureka (EmployeeSearchService) работает.Мой Eureka Server показывает, что Служба Сотрудника (Клиент) зарегистрирована.Но мой сервис Employee недоступен с localhost: 8081 / URL.

реестр, показывающий следующее:

EMPLOYEE-SEARCH-SERVICE     n/a (1)     (1)     UP (1) - 
W1651507.northamerica.cerner.net:employee-search-service:8081

Но когда я нажимаю W1651507.northamerica.cerner.net:employee-search-service:8081/employee/findall, который должен быть правильным URL, он показывает ошибку 404.

Клиентский контроллер Eureka:

package com.example.controller;

import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.EmployeeSearchService.domain.model.Employee;
import com.example.service.EmployeeSearchService;

@RefreshScope
@RestController
public class EmployeeSearchController {
    @Autowired
    EmployeeSearchService employeeSearchService;

    @RequestMapping("/employee/find/{id}")
    public Employee findById(@PathVariable Long id) {
        return employeeSearchService.findById(id);
    }

    @RequestMapping("/employee/findall")
    public Collection<Employee> findAll() {
        return employeeSearchService.findAll();
    }
}
#spring.application.name=EmployeeSearch
spring.application.name=employee-search-service
spring.cloud.config.uri=http://localhost:9090
eureka.client.serviceUrl.defaultZone:http://localhost:8761/eureka/
server.port=8081
security.basic.enable: false   
management.security.enabled: false

eureka.instance.hostname=localhost
#hostname: localhost

Код сервера Eureka:

bootstrap.prperties на сервере Eureka:

spring.application.name=EmployeeEurekaServer
eureka.client.serviceUrl.defaultZone=http://localhost:8761/
#server.port=9091
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

package com.example.EmployeeEurekaServer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer
@SpringBootApplication
public class EmployeeEurekaServerApplication {
 public static void main(String[] args) {
  SpringApplication.run(EmployeeEurekaServerApplication.class, args);
 }
}
---------------------------------------------------------------------

Config Server Code :
bootstrap.properties :

server.port=9090
#spring.cloud.config.server.native.searchLocations=file:///${user.home}/MicroService/centralProperties/
spring.cloud.config.server.native.searchLocations=file:///C:/PERSONAL/JAVA_PERSONAL_WORKSPACE/SpringWorkSpace2018/MicroserviceConfigServer/MicroService/centralProperties
SPRING_PROFILES_ACTIVE=native

package com.example.MicroserviceConfigServer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
--------------------------------------
@EnableConfigServer
@SpringBootApplication
public class ConfigServer {
 public static void main(String[] args) {
  SpringApplication.run(ConfigServer.class, args);
 }
}

Клиент зарегистрирован на сервере Eureka.Найдите подробности:

EMPLOYEE-SEARCH-SERVICE     n/a (1)     (1)     UP (1) -   
W1651507.northamerica.cerner.net:employee-search-service:8081

Я ожидал, что W1651507.northamerica.cerner.net:employee-search-service:8081/employee/findall даст какой-то вывод, но не даст никакого ответа.

Почему зарегистрированный URL не работает?

...