Hibernate EntityManager没有持久性提供程序

Hibernate EntityManager没有持久性提供程序,hibernate,jpa,Hibernate,Jpa,我有一个使用hibernate、JPA、Tomcat和JSF的项目。 无论如何,我已经尝试解决这个错误超过两个小时,但没有成功。 我所有的罐子都包括在内,但这个错误不想给我一个喙。 这是我的错误: log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version). log4j:WARN Please initialize the log4j system properly. log4

我有一个使用hibernate、JPA、Tomcat和JSF的项目。 无论如何,我已经尝试解决这个错误超过两个小时,但没有成功。 我所有的罐子都包括在内,但这个错误不想给我一个喙。 这是我的错误:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named examplePersistenceUnit
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:56)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
    at test.TestBase.<init>(TestBase.java:15)
    at test.TestCandidat.<init>(TestCandidat.java:14)
    at test.TestCandidat.main(TestCandidat.java:83)
log4j:WARN找不到记录器(org.hibernate.cfg.annotations.Version)的追加器。
log4j:警告请正确初始化log4j系统。
log4j:请参阅http://logging.apache.org/log4j/1.2/faq.html#noconfig 更多信息。
线程“main”javax.persistence.PersistenceException中出现异常:没有名为examplePersistenceUnit的EntityManager的持久性提供程序
位于javax.persistence.persistence.createEntityManagerFactory(persistence.java:56)
位于javax.persistence.persistence.createEntityManagerFactory(persistence.java:34)
TestBase.(TestBase.java:15)
testcandidate.(testcandidate.java:14)
位于test.testcandidate.main(testcandidate.java:83)
这是我的persistence.xml:

<?xml version="1.0" 

encoding="UTF-8"?>
<persistence>
    <persistence-unit name="examplePersistenceUnit"
        transaction-type="RESOURCE_LOCAL">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="false" />

            <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
            <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/RecrutementDB" />
            <property name="hibernate.connection.username" value="root" />
            <property name="hibernate.connection.password" value="3031989" />

            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
            <property name="hibernate.hbm2ddl.auto" value="create" />
        </properties>
    </persistence-unit>
</persistence>

org.hibernate.ejb.HibernatePersistence

首先在WEB-INF下添加log4j.properties文件,并确保META-INF文件夹下的persistence.xml。如果没有帮助,您可能在persistence.xml中有语法错误。xml

有一件事我不知道,那就是我在persistence.xml中有这个警告“没有语法约束(DTD或xml模式)”为文档检测到。“-这可能有帮助吗?特别是namespace declaration.ir,通过添加属性文件,我成功地发出了lo4j警告,因此我可以找到我的问题,谢谢您的回答