79692912

Date: 2025-07-07 13:26:14
Score: 1
Natty:
Report link

Use @PostConstruct annotation that allows to make a necessary load embracing Spring bean model. Method under @PostConstruct executes once in a bean life time.

@Slf4j
@Component
public class PokemonViewToPokemonEntityConverter implements Converter<PokemonView, PokemonEntity> {

    private HashMap<String, Integer> pokemonTypes;

    @PostConstruct
    private void init() {
      pokemonTypes = myDbService.load();
    }

    // ...
}

Source:

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: biggujo