Present in Spring 5.1.2.RELEASE

Created 2 beans of type LocalContainerEntityManagerFactoryBean, annotated one with @Primary. Neither EntityManager proxy (of type SharedEntityManagerCreator$SharedEntityManagerInvocationHandler) gets marked as primary when trying to get it through @Autowired

Seems related to issue #22675

Beans goes through DefaultListableBeanFactory.isPrimary() with beanName as "org.springframework.orm.jpa.SharedEntityManagerCreator#0" and "org.springframework.orm.jpa.SharedEntityManagerCreator#1". Both do not start with a factory dereference prefix, so isPrimary() does not check the Bean's parent BeanFactory for the @Primary annotation, so the running application cannot decide which to autowire.

Comment From: snicoll

Present in Spring 5.1.2.RELEASE

The issue that you've referenced has been fixed in Spring Framework 5.2.x. If you can reproduce with a supported version of the framework, please attach a small sample that we can run ourselves and we can reopen.