Allows to run Spring Boot Admin and two sample apps (hello world, health simulator) with service discovery via Nacos.
This Readme will guide you through all setup steps for the infrastructure.
- Java
- Maven
- Docker and Docker Compose
You can run the whole build and start all apps in docker containers with the following script or follow the step-by-step guide below.
chmod u+x buildAndRunAll.sh
./buildAndRunAll.sh
docker-compose down -v
docker run --name nacos-standalone -e MODE=standalone -p 8848:8848 -p 9848:9848 -d nacos/nacos-server:v2.2.3-slim
To let Spring Boot Admin automatically discover another Spring Boot app in this scenario, do the following:
- Add the Nacos discovery starter dependency to your app:
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> <version>2022.0.0.0-RC2</version> </dependency>
- Make sure
spring.application.name
is set. - Set
spring.cloud.nacos.discovery.server-addr
to point to the Nacos server:spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
This will make your app automatically register with Nacos on startup. It will not show up in Spring Boot Admin yet, since the Spring Boot Admin in this example is configured to filter instances by metadata (see spring.boot.admin.discovery.instances-metadata
).
- Add instance metadata to let Spring Boot Admin discover your app:
spring.cloud.nacos.discovery.metadata.spring-boot-admin=true