If I have 2 beans in my ApplicationContext implementing the same interface I can mark one of them as primary in the bean definition. This bean is prefered for dependency injection.
Is there a way to get direct access using the ApplicationContext to the primary one without DI?
First you need your BeanFactory/ApplicationContext. You can retrieve it for example by implementing BeanFactoryAware. Assuming it is ConfigurableListableBeanFactory, you can check what’s primary for given type like this: