Maven/Eclipse:在类路径中找不到任何META-INF/persistence.xml文件

And*_*tin 11 java eclipse maven

我知道关于这个问题还有其他问题,但没有一个解决方案对我有用.我正在使用maven在eclipse中构建一个java项目,我在src/main/resource/META_INF文件夹中有我的persistence.xml文件.但是当我尝试安装mvn时,我总是得到这个错误:

No Persistence provider for EntityManager named plasma.persistence
Run Code Online (Sandbox Code Playgroud)

通过控制台输出查看它似乎是由此引起的:

[org.hibernate.jpa.boot.internal.PersistenceXmlParser] - HHH000318: Could not find any META-INF/persistence.xml file in the classpath
Run Code Online (Sandbox Code Playgroud)

这是我的persistence.xml文件:

<persistence xmlns="http://java.sun.com/xml/ns/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">
<persistence-unit name="plasma.persistence" transaction-type="RESOURCE_LOCAL">
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.spatial.dialect.postgis.PostgisDialect"/>
        <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
        <property name="hibernate.connection.url" value="jdbc:postgresql://localhost:5432:xxxxx"/>
        <property name="hibernate.connection.username" value="xxxxx"/>
        <property name="hibernate.connection.password" value="xxxxx"/>
        <property name="hibernate.connection.pool_size" value="5"/>
        <property name="hibernate.show_sql" value="true"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.max_fetch_depth" value="5"/>
        <property name="hibernate.hbm2ddl.auto" value="update"/>
    </properties>
</persistence-unit>
Run Code Online (Sandbox Code Playgroud)

我试图右键单击项目并将META_INF文件夹添加到构建路径,但它仍然无效.有任何想法吗?

use*_*849 33

持久性文件的正确主页应该是src/main/resources/META-INF.在这个问题中,你提到了src/main/resource/META_INF.注意,资源中应该有's',META-INF中应该有短划线( - ),而不是下划线.那些问题只是错别字吗?如果没有,修复路径,它应该工作.