How to Enable Nacos Service Discovery with Spring Boot Admin After Startup

After integrating Nacos as the service registry with Spring Boot Admin, the author discovered that only services started before the admin were monitored, examined how Eureka and Consul handle HeartbeatEvent, and resolved the issue by copying and configuring NacosWatch code from the official spring‑cloud‑alibaba repository, enabling automatic service registration.

Java Architecture Diary
Java Architecture Diary
Java Architecture Diary
How to Enable Nacos Service Discovery with Spring Boot Admin After Startup

Introduction

The author is rebuilding microservices in a new company, choosing Nacos as the service registry instead of Eureka, and using Mica as the microservice core. The source code is available at https://gitee.com/596392912/mica.

Problem

After integrating Nacos with Spring Boot Admin, only services started before the admin are monitored. Spring Boot Admin relies on HeartbeatEvent for new service registration. The author notes that Eureka and Consul clients also send this event.

Eureka

Consul

Solution

The author initially considered implementing the feature and submitting it upstream, but discovered that the official spring-cloud-alibaba repository already includes the functionality. Since it has not been released yet, the author copied the relevant code into their own project.

Copy NacosWatch

Note that there may be errors; you can hard‑code the required properties.

/**
 * watch delay,duration to pull new service from nacos server.
 */
private long watchDelay = 30000;

Add NacosWatch Auto‑Configuration

/**
 * NacosWatch auto‑configuration
 *
 * @author L.cm
 */
@Configuration
public class NacosWatchAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(value = "spring.cloud.nacos.discovery.watch.enabled", matchIfMissing = true)
    public NacosWatch nacosWatch(NacosDiscoveryProperties nacosDiscoveryProperties) {
        return new NacosWatch(nacosDiscoveryProperties);
    }
}

Restart Spring Boot Admin, then start the other services; the new services are automatically synchronized to Spring Boot Admin—success!

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

javaNacosspring-boot-admin
Java Architecture Diary
Written by

Java Architecture Diary

Committed to sharing original, high‑quality technical articles; no fluff or promotional content.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.