Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@NacosConfigurationProperties无法注入yaml配置 #284

Open
yuxiao97 opened this issue Apr 21, 2022 · 0 comments
Open

@NacosConfigurationProperties无法注入yaml配置 #284

yuxiao97 opened this issue Apr 21, 2022 · 0 comments

Comments

@yuxiao97
Copy link

Issue Description

如题,使用@NacosConfigurationProperties将配置注入到POJO类时,无法注入相关值。
Type: bug report or feature request

相关组件版本如下:

SpringBoot: 2.5.2

<dependency>
    <groupId>com.alibaba.nacos</groupId>
    <artifactId>nacos-spring-context</artifactId>
    <version>1.1.1</version>
</dependency>

Describe what happened (or what feature you want)

Config Class如下:

@Data
@Configuration
@NacosConfigurationProperties(prefix = "simple", autoRefreshed=true, type = ConfigType.YAML, ignoreNestedProperties = true,
        dataId = "${nacos.config.dataId}", groupId = "${nacos.config.groupId}")
public class SimpleObjConfig {

    private String name;

    private String school;

    private Integer age;

}

yaml配置如下:
image

@NacosConfigurationProperteis注入效果如下:
image

Describe what you expected to happen

使用@NacosConfigurationiProperties能正确注入相关配置的值,并且在配置中心修改后,Config Bean中的值是可以动态改变的。

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

Anything else we need to know?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant