java - HHH10001002:使用 Hibernate 内置连接池(不用于生产!)
问题描述
在部署我的应用程序时,我收到了这个休眠警告(两次):
WARN org.hibernate.orm.connections.pooling - HHH10001002: Using Hibernate built-in connection pool (not for production use!)
我不想使用 Hibernate 中的这些内置连接池,也不想使用 C3PO 之类的任何其他实现。
我尝试了很多东西,但我无法使用我的 Weblogic应用程序服务器的连接池。
我的persistence.xml:
<persistence...
<persistence-unit name="MY-PERSISTENCE-UNIT">
<description>Hibernate JPA Configuration</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>some classes...</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.connection.datasource" value="jdbc/myDS"/>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
<property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jndi.class" value="weblogic.jndi.WLInitialContextFactory"/>
</properties>
</persistence-unit>
</persistence>
weblogic.xml:
...
<resource-description>
<res-ref-name>jdbc/myDS</res-ref-name>
<jndi-name>myDS</jndi-name>
</resource-description>
...
网页.xml:
...
<resource-ref>
<res-ref-name>jdbc/myDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
PS:我通过 Entitymanager 获得连接,但我没有任何 context.xml。
我能做些什么?有人可以帮忙吗?
解决方案
您不应该使用属性设置数据源。<jta-data-source>
使用元素将数据源提供给实体管理器有标准的方法。
你只需要这样的东西:
<persistence...
<persistence-unit name="MY-PERSISTENCE-UNIT">
<description>Hibernate JPA Configuration</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<jta-data-source>jdbc/myDS</jta-data-source>
<class>some classes...</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle12cDialect"/>
</properties>
</persistence-unit>
</persistence>
推荐阅读
- flutter - 颤振错误:TabBarView 没有 TabController
- python - 如何从“列表”视图中分割部分字段 – django rest 框架
- c - 操作系统开发。PS/2 鼠标不工作。移动鼠标时不触发 IRQ 12
- c++ - Move insertion with unordered_map having multiple values
- kiwi-tcms - 评论启用富文本
- python - 安装 ssh-2 时命令出错,退出状态为 1
- node.js - 通过表单数据正文类型上传文件时邮递员错误
- github - 如何在 github 操作中设置环境变量
- mysql - 如果值为 null 或为空,MySQL 将忽略 where 条件
- c# - Asp.net Core 5.0 在使用时似乎没有 httpContext.Session.GetString 作为方法