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:
<dependency>
<groupId>io.quarkiverse.config</groupId>
<artifactId>quarkus-config-nacos</artifactId>
<version>2.4.0</version>
</dependency>
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: |
host:port |
required |
The Nacos username. Environment variable: |
string |
|
The Nacos password. Environment variable: |
string |
|
The Nacos namespace. Environment variable: |
string |
|
The Nacos configuration name. Environment variable: |
string |
required |
The Nacos configuration group. Environment variable: |
string |
|
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: |
boolean |
|
The container image name to use. Environment variable: |
string |
|
The Nacos namespace. Environment variable: |
string |
|
The Nacos configuration name. Environment variable: |
string |
|
The Nacos configuration group. Environment variable: |
string |
|
The configuration to load in Properties format. Environment variable: |
string |
|