在部署我的应用程序时,我收到此 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>
...
web.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>
关于java - HHH10001002 : Using Hibernate built-in connection pool (not for production use!),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60302533/