嗨,人们在创建我的JAXB解析器时遇到了一个非常奇怪的问题。当我尝试从Eclipse生成JAXB类时,在一个类中它显示了一个非常奇怪的错误,即

Access restriction: The type QName is not accessible due to restriction on required library /usr/lib/jvm/jdk1.7.0_02/jre/lib/rt.jar

这是我的课
package generated;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
//import javax.xml.namespace.QName;
import javax.xml.namespace.*;


@XmlRegistry
public class ObjectFactory {

在这条线上,我正在获取错误消息

私有(private)最终静态QName _ExpenseReport_QNAME =新的QName(“”,“expenseReport”);
    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: generated
     *
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link ExpenseT }
     *
     */
    public ExpenseT createExpenseT() {
        return new ExpenseT();
    }

    /**
     * Create an instance of {@link UserT }
     *
     */
    public UserT createUserT() {
        return new UserT();
    }

    /**
     * Create an instance of {@link ItemT }
     *
     */
    public ItemT createItemT() {
        return new ItemT();
    }

    /**
     * Create an instance of {@link ItemListT }
     *
     */
    public ItemListT createItemListT() {
        return new ItemListT();
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link ExpenseT }{@code >}}
     *
     */
    @XmlElementDecl(namespace = "", name = "expenseReport")
    public JAXBElement<ExpenseT> createExpenseReport(ExpenseT value) {
        return new JAXBElement<ExpenseT>(_ExpenseReport_QNAME, ExpenseT.class, null, value);
    }

}

最佳答案

当您的类路径引用的是JRE而不是项目所在的JDK时,会发生此问题,请执行以下操作:



删除附带的运行时并添加jdk运行时,它现在应该可以解决您的问题。

关于jakarta-ee - 对jdk1.7/jre/lib/rt.jar的访问限制,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10428984/

10-09 13:44