This topic explains how to use nacos-config-spring-boot-starter.

Get the Starter

To get the nacos-config-spring-boot-starter, add the following configuration to the pom.xml file in the Maven project.



  1. Configure the connection in

    # The value of endpoint and namespace can be found in namespace details.
    # We recommend that you use the accessKey and secretKey of the RAM account
  2. Use @NacosPropertySource to load the configuration source with the dataId of, and turn on automatic update.

    @NacosPropertySource(dataId = "", autoRefreshed = true)
    public class NacosConfigApplication {
        public static void main(String[] args) {
  , args);
  3. Set the value of the properties with the @NacosValue annotation of Nacos.

    public class ConfigController {
        @NacosValue("${connectTimeoutInMills:5000}", autoRefreshed = true)
        private int connectTimeoutInMills;
        @RequestMapping(value = "/get", method = GET)
        public int get() {
            return connectTimeoutInMills;
  4. Open the ACM console and create a new configuration under the corresponding namespace.

    • Data ID:

    • Select Properties for the configuration format, and put the specific key-value pairs in the configuration body:


    For the complete sample code, see nacos-spring-boot-config-example.

Related documents