Getting application context from a CommandLinerRunner
Autowiring would work, either as a field
@Autowired
private ApplicationContext context;
or a method
@Autowired
public void context(ApplicationContext context) { this.context = context; }
Same as ApplicationContextAware
really.
It's a smell in any case - maybe if you think about your use case you will find a way to do it without the context?