gpt4 book ai didi

java - 没有遇到合适的连接提供程序 : JPA Hibernate

转载 作者:行者123 更新时间:2023-11-30 11:17:05 25 4
gpt4 key购买 nike

我正在尝试使用 root 用户和密码连接到我的本地数据库:password。我只是想学习这些东西,很难开始。我知道需要为 entitymanager 和交易系统提供一个连接,但我想我已经在我的持久性文件中指定了。最后,我正在运行独立的 jboss,所以也许我还需要配置服务器端,但我觉得一切都应该在我的容器中配置。最后,我没有 hibernate.cfg.xml 文件,因为所有内容都为我的实体添加了注释。

<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="persistenceUnit"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/hello" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="password" />
<property name="hbm2ddl.auto" value="create" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
</properties>
</persistence-unit>
</persistence>

编辑

13:54:17,474 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-16) JBAS015876: Starting deployment of "hello.war" (runtime-name: "hello.war")
13:54:17,474 INFO [org.jboss.web] (ServerService Thread Pool -- 529) JBAS018224: Unregister web context: /taylor
13:54:17,508 INFO [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015877: Stopped deployment taylor.war (runtime-name: taylor.war) in 34ms
13:54:17,578 INFO [org.jboss.as.jpa] (MSC service thread 1-10) JBAS011401: Read persistence.xml for persistenceUnit
13:54:17,604 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
13:54:17,604 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-8) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
13:54:17,606 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 533) JBAS011402: Starting Persistence Unit Service 'hello.war#persistenceUnit'
13:54:17,607 INFO [org.hibernate.ejb.Ejb3Configuration] (ServerService Thread Pool -- 533) HHH000204: Processing PersistenceUnitInfo [
name: persistenceUnit
...]
13:54:17,616 WARN [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (ServerService Thread Pool -- 533) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
13:54:17,617 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 533) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
13:54:17,617 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (ServerService Thread Pool -- 533) HHH000422: Disabling contextual LOB creation as connection was null
13:54:17,621 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (ServerService Thread Pool -- 533) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
13:54:17,621 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 533) HHH000397: Using ASTQueryTranslatorFactory
13:54:17,630 WARN [org.hibernate.internal.SessionFactoryImpl] (ServerService Thread Pool -- 533) HHH000008: JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()
13:54:17,632 INFO [org.jboss.web] (ServerService Thread Pool -- 536) JBAS018210: Register web context: /helloMan
13:54:17,639 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "taylor.war" (runtime-name: "taylor.war")
13:54:17,639 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "hello.war" (runtime-name : "hello.war")

最佳答案

根据我的经验,我可以说出一些事情:

  1. 我没用过<provider>标签或 hibernate.dialect属性(property)曾经,这可能是个问题。
  2. 我从未使用过其他属性 比hibernate.something.something或应用程序服务器特定的标签,如 jboss.something.somethingpersistence.xml .您正在使用不同的 属性的“家族”,这可能是个问题。
  3. 更多基本提示 - 有助于了解您的环境。应用服务器(Tomcat、JBoss等)、Java版本等。

关于java - 没有遇到合适的连接提供程序 : JPA Hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24563533/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com