Maven / Eclipse:在类路径中找不到任何META-INF / persistence.xml文件 [英] Maven/Eclipse: Could not find any META-INF/persistence.xml file in the classpath

查看:581
本文介绍了Maven / Eclipse:在类路径中找不到任何META-INF / persistence.xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 没有EntityManager的持久性提供者名为plasma.persistence 

通过控制台输出查看似乎是由此造成的:

  [org.hibernate.jpa.boot.internal.PersistenceXmlParser]  -  HHH000318:在类路径中找不到任何META-INF / persistence.xml文件

这是我的persistence.xml文件:

 code>< persistence xmlns =http://java.sun.com/xml/ns/persistence
xmlns:xsi =http://www.w3.org/2001/XMLSchema-实例
xsi:schemaLocation =http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd
版本= 2.0 >
< persistence-unit name =plasma.persistencetransaction-type =RESOURCE_LOCAL>
<属性>
< property name =hibernate.dialectvalue =org.hibernate.spatial.dialect.postgis.PostgisDialect/>
< property name =hibernate.connection.driver_classvalue =org.postgresql.Driver/>
< property name =hibernate.connection.urlvalue =jdbc:postgresql:// localhost:5432:xxxxx/>
< property name =hibernate.connection.usernamevalue =xxxxx/>
< property name =hibernate.connection.passwordvalue =xxxxx/>
< property name =hibernate.connection.pool_sizevalue =5/>
< property name =hibernate.show_sqlvalue =true/>
< property name =hibernate.format_sqlvalue =true/>
< property name =hibernate.max_fetch_depthvalue =5/>
< property name =hibernate.hbm2ddl.autovalue =update/>
< / properties>
< / persistence-unit>



我已经尝试右键单击该项目并将META_INF文件夹添加到构建路径,并且仍然不起作用。任何想法?

解决方案

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


I know there are other questions on SO about this issue, but none of the solutions have worked for me. I'm using maven to build a java project in eclipse, and I have my persistence.xml file in the src/main/resource/META_INF folder. But when I try to mvn install, I always get this error:

No Persistence provider for EntityManager named plasma.persistence

Looking through the console output it appears to be caused by this:

[org.hibernate.jpa.boot.internal.PersistenceXmlParser] - HHH000318: Could not find any META-INF/persistence.xml file in the classpath

Here is my persistence.xml file:

<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>

I have tried right clicking on the project and adding the META_INF folder to the build path, and it still doesn't work. Any ideas?

解决方案

The proper home for the persistence file should be src/main/resources/META-INF. In the question, you mention src/main/resource/META_INF. Note, there should be an 's' in resources and a dash (-) in META-INF, not an underscore. Are those just typos in the question? If not, fix the path and it should work.

这篇关于Maven / Eclipse:在类路径中找不到任何META-INF / persistence.xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆