1

I have this file (campanhas.conf) working well:

campanhas = [
{
    codigo = CT1
    nome = Campanha 1
    descricao = Campanha de Teste
    modoAtendimento = power
    grupoDAC = grupo1

}
{
    codigo = CT2
    nome = Campanha 2
    descricao = Testeee
    modoAtendimento = preview
    grupoDAC= grupo2
}
]

But I'd like to declare objects before to be easier to order them later. Something like this:

CT1{
    codigo = CT1
    nome = Campanha 1
    descricao = Campanha de Teste
    modoAtendimento = power
    grupoDAC = grupo1

}

CT2{
    codigo = CT2
    nome = Campanha 2
    descricao = Testeee
    modoAtendimento = preview
    grupoDAC= grupo2
}

campanhas = [${CT2}, ${CT1}]

But it Says:

substitution not resolved: ConfigReference(${CT2})

How can I create an array of previously declared objects?

Guanxi
  • 3,103
  • 21
  • 38
Camilla
  • 489
  • 5
  • 14

1 Answers1

0

There wasn't any problem with hocon file itself.

When reading the conf I was only using parseFile(). I had to use the resolve().

    private Config loadConfig(File file) {

    Config cfg = ConfigFactory.parseFile(file);
    if (cfg == null)
        throw new CoreRuntimeException(MessageFormatter.format(
                "Arquivo {} não foi encontrado no CLASSPATH.", file));
    cfg = cfg.resolve();
    return cfg;
}
Camilla
  • 489
  • 5
  • 14