gpt4 book ai didi

jakarta-ee - jdk1.7/jre/lib/rt.jar的访问限制

转载 作者:IT老高 更新时间:2023-10-28 21:04:11 28 4
gpt4 key购买 nike

大家好,我在创建 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 final static QName _ExpenseReport_QNAME = new 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 时会出现此问题,做一件事去

Build Path > Libraries

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

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

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com