【发布时间】:2017-01-22 07:22:02
【问题描述】:
我有部署在 Weblogic 12.1.2 上的应用程序,我们想使用 weblogic 提供的实体管理器,而不是 org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean。我在下面尝试过,但缺少一些配置。
使用 PSU 名称更新了 web.xml
<persistence-context-ref>
<persistence-context-ref-name>persistance/PSU_NAME</persistence-context-ref-name>
<persistence-unit-name>PSU_NAME</persistence-unit-name>
</persistence-context-ref>
用
更新了application.xml<jee:jndi-lookup id="entityManagerFactory" jndi-name="persistance/PSU_NAME">
</jee:jndi-lookup>
在部署时它说 javax.persistence.EntityManager 不能被注入。我想我错过了什么。
注意:我知道如何使用 org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean 及其工作正常。
【问题讨论】:
-
你能发布堆栈跟踪吗? Spring 可能无法注入 EntityManager 的原因有很多,并且堆栈跟踪将包含有关它的信息。
-
如果 jndi 查找失败,您可以在自己的 bean 中进行手动查找,以尝试注册 entityManagerFactory 的名称。说到这里:你确定,persistance/PSU_NAME 不是错字,应该是 persistence/PSU_NAME
标签: spring jpa spring-data weblogic eclipselink