{"record":{"id":"888eaedae0d8c56f","repo":"alibaba/spring-cloud-alibaba","slug":"spring-nacos-config-proxy-druid-data-id-is-require","errorCode":null,"errorMessage":"spring.nacos.config.proxy.druid.data-id is required","messagePattern":"spring\\.nacos\\.config\\.proxy\\.druid\\.data-id is required","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/proxy/druid/NacosDruidFilterConfiguration.java","lineNumber":36,"sourceCode":"\nimport com.alibaba.cloud.nacos.NacosConfigManager;\n\nimport org.springframework.boot.autoconfigure.condition.ConditionalOnBean;\nimport org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\nimport org.springframework.core.env.Environment;\n\n@Configuration\npublic class NacosDruidFilterConfiguration {\n\n\t@Bean\n\t@ConditionalOnProperty(value = \"spring.nacos.config.proxy.druid.enabled\", havingValue = \"true\")\n\t@ConditionalOnBean(NacosConfigManager.class)\n\tpublic NacosDruidConfigFilter nacosDruidFilter(Environment environment) {\n\t\tString proxyDataId = environment.getProperty(\"spring.nacos.config.proxy.druid.data-id\");\n\t\tif (proxyDataId == null) {\n\t\t\tthrow new IllegalStateException(\"spring.nacos.config.proxy.druid.data-id is required\");\n\t\t}\n\t\treturn new NacosDruidConfigFilter(proxyDataId);\n\t}\n\n}\n","sourceCodeStart":18,"sourceCodeEnd":42,"githubUrl":"https://github.com/alibaba/spring-cloud-alibaba/blob/115d5901102009492e05d5ec18c3f79cad4077d0/spring-cloud-alibaba-starters/spring-alibaba-nacos-config/src/main/java/com/alibaba/cloud/nacos/proxy/druid/NacosDruidFilterConfiguration.java#L18-L42","documentation":"Thrown by the NacosDruidFilterConfiguration @Bean method during Spring context startup. The bean is only created when 'spring.nacos.config.proxy.druid.enabled' is set to 'true' AND a NacosConfigManager bean exists. The method then reads 'spring.nacos.config.proxy.druid.data-id' from the Environment; if that property is absent (getProperty returns null), the bean cannot be constructed and startup aborts with IllegalStateException. The proxy feature routes Druid SQL monitoring configuration through Nacos, so it needs to know which Nacos dataId holds the Druid config.","triggerScenarios":"Setting spring.nacos.config.proxy.druid.enabled=true in application.yml/properties without also setting spring.nacos.config.proxy.druid.data-id. The NacosConfigManager bean must also be present (it is auto-configured when spring-cloud-starter-alibaba-nacos-config is on the classpath and Nacos config server-addr is configured). The @ConditionalOnProperty match means the @Bean method is invoked, and the null check at line 35 fires.","commonSituations":"1) A developer copies a partial config snippet that enables the druid proxy but forgets the data-id. 2) Environment-specific overrides (dev vs prod profile) set enabled=true but the profile-specific data-id is missing. 3) The data-id key is misspelled or uses wrong hyphen/camelCase convention so Spring does not bind it.","solutions":["Add spring.nacos.config.proxy.druid.data-id=<your-druid-config-data-id> to application.yml, ensuring the dataId exists in your Nacos config server.","If you did not intend to use the Druid proxy, remove or set spring.nacos.config.proxy.druid.enabled=false (or omit it entirely — the default is disabled).","Verify the property key is spelled exactly 'spring.nacos.config.proxy.druid.data-id' — Spring relaxed binding accepts camelCase or underscores, but typos in the stem will not match."],"exampleFix":"# before (broken)\nspring:\n  nacos:\n    config:\n      proxy:\n        druid:\n          enabled: true\n\n# after (fixed)\nspring:\n  nacos:\n    config:\n      proxy:\n        druid:\n          enabled: true\n          data-id: druid-sql-config.yaml","handlingStrategy":"validation","validationCode":"// Before enabling the druid proxy, verify the data-id property exists\n@Value(\"${spring.nacos.config.proxy.druid.enabled:false}\")\nboolean druidEnabled;\n\n@Value(\"${spring.nacos.config.proxy.druid.data-id:}\")\nString druidDataId;\n\n// In a @PostConstruct or configuration check:\nif (druidEnabled && !StringUtils.hasText(druidDataId)) {\n    throw new IllegalStateException(\n        \"spring.nacos.config.proxy.druid.data-id must be set when druid proxy is enabled\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set data-id in the same YAML block where you set enabled=true to avoid partial configuration.","Use a custom @ConfigurationProperties validation bean that checks related properties together.","Add a startup health check that asserts the druid dataId exists in Nacos before the bean is created."],"tags":["nacos","configuration","druid","spring-boot","startup","bean-creation"],"backgroundTag":null,"analyzedSha":"115d5901102009492e05d5ec18c3f79cad4077d0","analyzedAt":"2026-08-14T04:47:13.900Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}