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: falseサーバーの application.yaml から を削除します。サーバーは、クライアントを確認するためにレジストリをフェッチする必要があります...

ところで: 同じホスト上でランダムなポートを使用して複数のインスタンスを実行する場合は、instanceId を設定する必要があります。それ以外の場合、SBA はインスタンス間で異なりません。

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