How do I properly configure an EntityManager in a jersey / hk2 application?
问题 I have a jersey-2 / hk2 application which uses JPA persistence. The EntityManager is bound at startup like this public MyApplication() { // ... register(new AbstractBinder() { @Override public void configure() { bindFactory(EmFactory.class) .to(EntityManager.class) .in(RequestScoped.class); } }); } with the factory class being public class EmFactory implements Factory<EntityManager> { private static final String PERSISTENCE_UNIT = \"unit\"; private EntityManagerFactory emf; private