找不到符号方法 required() javax.xml.bind.annotation.XmlElementRef

Sel*_*ran 4 java spring jaxb

使用 jdk 1.6 时出现以下错误,但它在 1.7 中工作

cannot find symbol method required() javax.xml.bind.annotation.XmlElementRef
Run Code Online (Sandbox Code Playgroud)

任何的想法?

    @XmlElementRef(name = "test", type = JAXBElement.class, required = false)
    protected JAXBElement<String> test;
Run Code Online (Sandbox Code Playgroud)

Mat*_*oka 5

在此处查看 Java 1.6 中 XmlElementRef 注释的文档。里面没有任何required元素。这就是您收到此异常的原因。