8000 NacosConfigurationProperties无法注入Map属性 · Issue #354 · nacos-group/nacos-spring-project · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

NacosConfigurationProperties无法注入Map属性 #354

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

Open
ipuoc opened this issue May 10, 2025 · 1 comment
Open

NacosConfigurationProperties无法注入Map属性 #354

ipuoc opened this issue May 10, 2025 · 1 comment

Comments

@ipuoc
Copy link
ipuoc commented May 10, 2025

nacos的配置如下:

free:
  share:
    url: precenter.es.com
    num: 3
  url: es.com

配置类如下:

@Data
@Configuration
//@ConfigurationProperties(prefix = "free")
@NacosConfigurationProperties(prefix = "free", groupId = "${nacos.config.group}", dataId = "${nacos.config.data-id}", autoRefreshed = true, type = ConfigType.PROPERTIES
)
public class FreeConfig {
    private Map<String, Object> share;
    private String url;
}

运行后,url属性成功注入,但是share为null,无法注入成功。添加ignoreUnknownFields = false属性后,运行报了如下错误:
Bean property 'free[share.url]' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter

@ipuoc
Copy link
Author
ipuoc commented May 10, 2025

切换数据源类型为properties也不行,Spring版本为3.4.4,jdk21

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
0