Another approach is to use context.initializer.classes=com.example.YourInitializer in a properties/yml file. I like this approach because then you can enable/disable initializers via environment specific props files.
It is mentioned only briefly in the spring boot docs