一个应用程序中的Eureka Server和Spring Boot Admin

Dom*_*omo 5 spring-boot netflix-eureka spring-boot-admin

我尝试在一个应用程序中运行Eureka Server和Spring Boot Admin Server(SBA Docu说这是可能的)。Eureka可以按预期工作,但Admin App仍显示零个“应用程序”。

Spring Boot版本2.0.3,Spring Boot管理版本2.0.1

尤里卡和SBA服务器

@SpringBootApplication
@EnableEurekaServer
@EnableDiscoveryClient
@EnableAdminServer
class KotlintestApplication
fun main(args: Array<String>) {
    SpringApplication.run(KotlintestApplication::class.java, *args)
}
Run Code Online (Sandbox Code Playgroud)

服务器bootstrap.yml

spring:
      application:
        name: server
Run Code Online (Sandbox Code Playgroud)

服务器application.yml

spring:
  boot:
   admin:
     context-path: /admin

eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://localhost:8080/eureka
Run Code Online (Sandbox Code Playgroud)

客户

@EnableDiscoveryClient
@SpringBootApplication
class KotlintestApplication

fun main(args: Array<String>) {
    SpringApplication.run(KotlintestApplication::class.java, *args)
}

@Configuration
class SecurityPermitAllConfig : WebSecurityConfigurerAdapter() {
    @Throws(Exception::class)
    override fun configure(http: HttpSecurity) {
        http.authorizeRequests().anyRequest().permitAll()
                .and().csrf().disable()
    }
}
Run Code Online (Sandbox Code Playgroud)

客户端bootstrap.yml

 spring:
      application:
        name: client
 server:
    port: 0
Run Code Online (Sandbox Code Playgroud)

客户端application.yml

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

eureka:
  instance:
    hostname: localhost
    health-check-url-path: /actuator/health
    status-page-url-path: /actuator/info
  client:
    serviceUrl:
      defaultZone: http://127.0.0.1:8080/eureka/
Run Code Online (Sandbox Code Playgroud)

Dom*_*omo 7

我自己找到了答案

fetchRegistry: false从服务器中删除application.yaml。服务器必须获取注册表才能看到客户端......

顺便说一句:如果您想在同一主机上使用随机端口运行多个实例,则应该设置一个instanceId。否则,SBA 无法在实例之间有所不同。

eureka:
  instance:
    instanceId : client-${random.uuid}
Run Code Online (Sandbox Code Playgroud)