When Dubbo uses version
3.0.0
or above, Nacos version2.0.0
or above is required. Please refer to nacos registry for Nacos version compatibility.
If the project has already enabled Nacos as a registry, no additional configuration is required.
If Nacos registry is not enabled, please refer to Add Nacos dependency for registry.
<dubbo:config-center address="nacos://127.0.0.1:8848"/>
or
dubbo
config-center
address: nacos://127.0.0.1:8848
or
dubbo.config-center.address=nacos://127.0.0.1:8848
or
ConfigCenterConfig configCenter = new ConfigCenterConfig();
configCenter.setAddress("nacos://127.0.0.1:8848");
For address
format, please refer to Nacos Registry - Enable Configuration
To enable authentication, please refer to Nacos Registry - Enable Authentication
1. Application enable config-center configuration
dubbo
config-center
address: nacos://127.0.0.1:2181
config-file: dubbo.properties # optional
config-file
- Key for global externalized configuration file, default is dubbo.properties
. It represents the key in the configuration center when storing the Dubbo configuration file remotely. It is generally not recommended to modify this configuration.
2. Add Configuration to Nacos Server
dataId is dubbo.properties
, group is the same as config-center, default is dubbo
if not set.
1. Application enable config-center configuration
dubbo
config-center
address: nacos://127.0.0.1:2181
app-config-file: dubbo.properties # optional
app-config-file
- Key for the application-specific externalized configuration file, such as app-name-dubbo.properties
, configured only when needing to override the global externalization config-file
.
2. Add Configuration to Nacos Server
dataId is dubbo.properties
, group is the application name demo-provider
.
dubbo
config-center
address: zookeeper://127.0.0.1:2181
group: dubbo-cluster1
namespace: dev1
For the configuration center, group
and namespace
should be consistent across the company (cluster) and avoid different values for different applications.
For more Nacos sdk/server supported parameter configurations, refer to Nacos Registry - More Configurations
For Nacos, all traffic governance rules and externalized configurations should be globally visible, thus applications in the same logical cluster must use the same namespace and group. The default value for namespace is public
and the default value for group is dubbo
. Applications must not modify the namespace and group without maintaining global consistency.
Changes to traffic governance rules are recommended to be made through dubbo-admin; for more details, see Dubbo’s supported traffic governance capabilities.
There are various types of traffic governance rules, and different types of rules have different suffixes for dataId: