0

I'm trying to map a configuration file that is located on the Windows FileSystem and populate a Hashmap with that information.

Following Spring documentation and tutorials I have the following:

A Spring bean with the configuration annotations

@Configuration
@ConfigurationProperties(prefix="contact")
@PropertySource("file:///E:/desarrollo/backend/java/proyectos/IW/contact.properties")
public class ContactConfig {

    private Map<String, String> groups = new HashMap<>();

    public Map<String, String> getContactGroups() {
        return this.groups;
    }

}

This is my configuration file:

contact.groups.Brasil = brasil
contact.groups.Argentina = argentina
contact.groups.Chile = chile
contact.groups.Spain = españa
contact.groups.Germany = alemania
contact.groups.Colombia = colombia
contact.groups.CostaRica = costa_rica
contact.groups.Ecuador = ecuador
contact.groups.Guatemala = guatemala
contact.groups.Mexico = mexico
contact.groups.Nicaragua = nicaragua
contact.groups.Panama = panama
contact.groups.Peru = peru
contact.groups.ElSalvador = el_salvador
contact.groups.Uruguay = uruguay
contact.groups.IZZIQoE = izzi_mexico

The application compiles but when I debug the Hashmap always come empty, I have tried with different config.properties formats but none of them works.

1 Answers1

0

I fixed it adding a setter method, now the hashmap gets the value from the property file.