7

I try to run Eureka Server and Spring Boot Admin Server in one Application (SBA Docu says this is possible). Eureka is working as intended but the Admin App still shows zero Applications.

Spring Boot Version 2.0.3, Spring Boot Admin Version 2.0.1

Eureka and SBA Server

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

Server bootstrap.yml

spring:
      application:
        name: server

Server application.yml

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

eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://localhost:8080/eureka

Client

@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()
    }
}

Client bootstrap.yml

 spring:
      application:
        name: client
 server:
    port: 0

Client 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/
4

1 回答 1

5

自己找到了答案

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

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

eureka:
  instance:
    instanceId : client-${random.uuid}
于 2018-06-26T07:16:50.707 回答