OpenJPA 2.1.1-找不到元素“持久性"的声明 [英] OpenJPA 2.1.1 - Cannot find the declaration of element 'persistence'

查看:127
本文介绍了OpenJPA 2.1.1-找不到元素“持久性"的声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了

I just downloaded http://www.apache.org/dyn/closer.cgi/openejb/4.0.0-beta-1/apache-tomee-1.0.0-beta-1-webprofile.zip to use OpenEJB with OpenJPA2.1.1. I can't get my persistence.xml working.

堆栈跟踪的顶部:

org.xml.sax.SAXException: 文件:/D:/Workspaces/sandbox/tomcat_ejb_jpa2_tomEE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/testEE/WEB-INF/classes/META-INF/persistence.xml [位置:第2行,C:248]:org.xml.sax.SAXParseException:cvc-elt.1: 找不到元素'persistence'的声明.

org.xml.sax.SAXException: file:/D:/Workspaces/sandbox/tomcat_ejb_jpa2_tomEE/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/testEE/WEB-INF/classes/META-INF/persistence.xml [Location: Line: 2, C: 248]: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'persistence'.

我的persistence.xml:

My persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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">
        <persistence-unit name="testEE">
        </persistence-unit>
</persistence>

我已经读过,应该使用名称空间声明(xmlns="http://java.sun.com/xml/ns/persistence")解决该问题,但是仍然无法解决问题.

I've read, that the problem should be solved with the namespace declaration (xmlns="http://java.sun.com/xml/ns/persistence"), but it still doesn't work.

推荐答案

<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
    version="2.0">
    <persistence-unit name="jpa-lib">
        <provider>org.apache.openjpa.persistence.PersistenceProviderImpl
        </provider>
        <class>com.dav.jpa.entity.Employee</class>
        <class>com.dav.jpa.entity.Department</class>
        <properties>
            <property name="openjpa.ConnectionURL" value="jdbc:oracle:thin:@localhost:1521:DVD" />
            <property name="openjpa.ConnectionDriverName" value="oracle.jdbc.OracleDriver" />
            <property name="openjpa.ConnectionUserName" value="scott" />
            <property name="openjpa.ConnectionPassword" value="tiger" />
            <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
        </properties>
    </persistence-unit>
</persistence>

这对我有用..

这篇关于OpenJPA 2.1.1-找不到元素“持久性"的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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