Skip to content

[Question] Does spring-alibaba-nacos-config support the @NacosValue annotation? #4336

@bengbengbalabalabeng

Description

@bengbengbalabalabeng

Which Component

<dependency>
	<groupId>com.alibaba.cloud</groupId>
	<artifactId>spring-alibaba-nacos-config</artifactId>
	<version>2025.1.0.0</version>
</dependency>

spring-alibaba-nacos-config + Spring Boot v4.0.6 (without any Cloud)

Describe what problem you have encountered

Demo Code

@RestController
class UserService {

	@Value(value = "${app.enable-cache}")
    //	@NacosConfig(group = "DEFAULT", dataId = "nacos-demo.yaml", key = "app.enable-cache")
    //	@NacosValue(value = "${app.enable-cache}", autoRefreshed = true)
	private boolean enableCache;

	@GetMapping("/info")
	String getInfo() {
		if (enableCache) {
			return "Info for cached";
		}
		return "Infos";
	}
}

@NacosConfig and @Value (None auto-refresh) work normally, but @NacosValue cannot be used.

Describe what information you have read

Initial investigation shows that com.alibaba.cloud.nacos.annotation.NacosAnnotationProcessor only includes listener for @NacosConfig, @NacosConfigListener, and NacosConfigKeysListener, but does not include the @NacosValue annotation.

So, my question is: does the spring-alibaba-nacos-config module not yet support the @NacosValue annotation, or is this annotation simply outside the scope of this module?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions