Quarkus Nacos Config

This extension provides support to read configuration from a Nacos server.

Getting Started

Add the io.quarkiverse.jberet:quarkus-jberet extension first to the build file:

pom.xml
<dependency>
    <groupId>io.quarkiverse.config</groupId>
    <artifactId>quarkus-config-nacos</artifactId>
    <version>2.4.0</version>
</dependency>
build.gradle
implementation("io.quarkiverse.config:quarkus-config-nacos:2.4.0")

To be able to connect to a Nacos server and retrieve the configuration, please configure the following properties:

quarkus.config.source.nacos.server-addr=[hostname]:[port]
quarkus.config.source.nacos.data-id=[dataId]

Please refer to Configuration Reference for more details.

Dev Services

If there is no Nacos available, Quarkus will automatically start one with Dev Services.

If you with to start your own server, you can do so with Docker:

docker run --name nacosc \
  -e MODE=standalone \
  -e NACOS_AUTH_ENABLE=false \
  -e NACOS_AUTH_TOKEN=SecretKey012345678901234567890123456789012345678901234567890123456789 \
  -e NACOS_AUTH_IDENTITY_KEY=serverIdentity \
  -e NACOS_AUTH_IDENTITY_VALUE=security \
  -p 8848:8848 -p 9848:9848 -p 8080:8080 \
  -d nacos/nacos-server:v3.1.0

For additional details, please check the Nacos Docker official image.

Configuration Reference

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Type

Default

The Nacos address.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_SERVER_ADDR

host:port

required

The Nacos username.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_USERNAME

string

The Nacos password.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_PASSWORD

string

The Nacos namespace.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_NAMESPACE

string

public

The Nacos configuration name.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_DATA_ID

string

required

The Nacos configuration group.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_GROUP

string

DEFAULT_GROUP

Dev Services allows Quarkus to automatically start Nacos in dev and test mode

Type

Default

If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present.

When DevServices is enabled Quarkus will attempt to automatically configure and start Nacos when running in Dev or Test mode and when Docker is running.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_DEVSERVICES_ENABLED

boolean

true

The container image name to use.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_DEVSERVICES_IMAGE_NAME

string

The Nacos namespace.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_DEVSERVICES_LOAD_CONFIG_NAMESPACE

string

public

The Nacos configuration name.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_DEVSERVICES_LOAD_CONFIG_DATA_ID

string

quarkus

The Nacos configuration group.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_DEVSERVICES_LOAD_CONFIG_GROUP

string

quarkus

The configuration to load in Properties format.

Environment variable: QUARKUS_CONFIG_SOURCE_NACOS_DEVSERVICES_LOAD_CONFIG_CONTENT

string

empty=