【问题标题】:How to access Weblogic Server Entity Manager如何访问 Weblogic Server 实体管理器
【发布时间】: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


【解决方案1】:

我能够通过

解决问题
<persistence-context-ref>
  <persistence-context-ref-name>PSU_NAME</persistence-context-ref-name>
  <persistence-unit-name>PSU_NAME</persistence-unit-name>
</persistence-context-ref>

<jee:jndi-lookup id="emf" jndi-name="PSU_NAME" />  

xmlns:jee="http://www.springframework.org/schema/jee"

【讨论】:

    猜你喜欢
    • 2015-09-29
    • 1970-01-01
    • 1970-01-01
    • 2015-09-01
    • 2018-02-20
    • 2012-06-28
    • 1970-01-01
    • 2018-12-21
    • 1970-01-01
    相关资源
    最近更新 更多