Two ways of defining Maps in property files

  1. Map as a Json Object
    account-types-and-weights=("single": 30, "joint": 10, "minor": 10, "proprietor": 10, "huf": 10, "legal entity": 10, "firm": 201
    

This requires:

a) an ObjectMapper to convert the Json object to a Pojo, and,

b) a Jackson TypeReference to preserve intended type

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Value;

@Component
public class PropertyParsing {
    @Value("$(account-types-and-weights)")

    private String accountTypesAndWeights;

    @PostConstruct
    @Override
    public void compute() throws JsonProcessingException {

        ObjectMapper objectMapper new ObjectMapper();
        Map<String, Integer> typeWeights = objectMapper.readValue( accountTypesAndWeights, new TypeReference<Map<String, Integer>>() {});