Skip to content

NacosConfigurationProperties无法注入Map属性 #354

@ipuoc

Description

@ipuoc

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

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