Spring boot Eureka服务器没有';t发现服务

Spring boot Eureka服务器没有';t发现服务,spring-boot,spring-cloud,Spring Boot,Spring Cloud,我刚刚开始通过SpringCloud学习微服务,首先我尝试重现本文中的基本示例。这是我的密码: 尤里卡服务器 @SpringBootApplication @EnableEurekaServer public class ServiceRegistryApplication { public static void main(String[] args) { System.setProperty("spring.config.name", "registration-serve

我刚刚开始通过SpringCloud学习微服务,首先我尝试重现本文中的基本示例。这是我的密码:

尤里卡服务器

@SpringBootApplication
@EnableEurekaServer
public class ServiceRegistryApplication {

  public static void main(String[] args) {
      System.setProperty("spring.config.name", "registration-server");
      SpringApplication.run(ServiceRegistryApplication.class, args);
  }
}
resources/registration-server.yml:

# Configure this Discovery Server
eureka:
  instance:
    hostname: localhost
  client:  # Not a client, don't register with yourself (unless running
           # multiple discovery servers for redundancy)
    registerWithEureka: false
    fetchRegistry: false

server:
  port: 1111   # HTTP (Tomcat) port
样本服务:

@SpringBootApplication
@EnableDiscoveryClient
public class AccountsServiceApplication {

  public static void main(String[] args) {
      System.setProperty("spring.config.name", "accounts-server");
      SpringApplication.run(AccountsServiceApplication.class, args);
  }
}
accounts-service.yml:

# Spring properties
spring:
  application:
     name: accounts-service

# Discovery Server Access
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:1111/eureka/

# HTTP Server
server:
  port: 2222   # HTTP (Tomcat) port
但当我运行这两个应用程序并转到localhost:1111时,我无法在应用程序列表中看到我的服务:

你能告诉我我做错了什么吗

编辑

应用更改后,出现以下行:
我有一个很好的解决方案,它很简单

遵循以下步骤:

1-Eureka服务器

@SpringBootApplication
@EnableEurekaServer
public class ServiceRegistryApplication {

  public static void main(String[] args) {

      SpringApplication.run(ServiceRegistryApplication.class, args);
  }
}
在application.properties中指定这些参数

spring.application.name=eureka-server
server.port=1111

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false 
spring.application.name=accounts-service
server.port=2222

eureka.client.service-url.default-zone=http://localhost:1111/eureka
2-抽样服务

@SpringBootApplication
@EnableDiscoveryClient
public class AccountsServiceApplication {

  public static void main(String[] args) {
      SpringApplication.run(AccountsServiceApplication.class, args);
  }
}
在application.properties中指定这些参数

spring.application.name=eureka-server
server.port=1111

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false 
spring.application.name=accounts-service
server.port=2222

eureka.client.service-url.default-zone=http://localhost:1111/eureka

不要忘记删除所有.yml属性文件。

谢谢您的回复。我做了你在答案中写的所有更改,但服务仍然不在列表中。唯一的变化是出现了
DS副本
行。(我在评论中添加了屏幕截图)您需要先启动EurekaServer,然后才能启动服务
帐户服务器
!=<代码>帐户服务因此基本上您的配置将被忽略。请粘贴两个应用程序中的服务器日志。很难说没有看到更多您的应用程序(依赖项和日志)。博客上有代码,你能发现其中的差异吗?