yml文件的list,map

时间:2025-04-02 20:10:11
country:
  countryConfig:
    aue:
      - lang: zh
        isDefault: true
      - lang: en
        isDefault: false
    hk:
      - lang: zh
        isDefault: true

上述所对应的java类为:

@Component
@ConfigurationProperties(prefix = "country")
@Data
public class CountryConfig {
    private Map<String, Set<LanguageConfig>> countryConfig;
}

@Data
class LanguageConfig {
    private String lang;
    private boolean isDefault;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != ()) return false;
        LanguageConfig that = (LanguageConfig) o;
        return (lang, );
    }

    @Override
    public int hashCode() {
        return (lang);
    }
}