JAXB 提供程序 Eclipselink MOXy 忽略 @XmlAccessorType(XmlAccessType.NONE)

发布于 2024-10-12 18:30:45 字数 584 浏览 3 评论 0原文

我在 package-info.java 中为 my.package 使用 @XmlAccessorType(XmlAccessType.NONE) ,这意味着 JAXB 应该只关心带注释的元素。然而,当我使用简单 POJO MOXy 的 un/marshalling 代码运行 JUnit 测试时,只会以这种方式尖叫每个类(甚至来自没有 jaxb.properties 的包或来自依赖项中引用的其他 Maven 模块):

Exception Description: The class other.maven.module.package.class requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.

我没有遇到过Metro 存在这样的问题(参考实现,但它对我的使用还有其他缺陷),不幸的是我真的无法以这种方式修改每个类。

I use @XmlAccessorType(XmlAccessType.NONE) in package-info.java for my.package which means JAXB should care only about annotated elements. However, when I run my JUnit test with un/marshalling code for simple POJO MOXy just screams about every class (even from package without jaxb.properties or from other maven modules which are referenced in dependencies) in this manner:

Exception Description: The class other.maven.module.package.class requires a zero argument constructor or a specified factory method.  Note that non-static inner classes do not have zero argument constructors and are not supported.

I haven't encountered such issue with Metro (reference implementation, but it has other defects for my usage) and unfortunately I really can't modify every class in this way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贪恋 2024-10-19 18:30:45

我已经能够验证这个问题,已输入以下错误来跟踪这个问题。

问题摘要:

对于以下对象模型:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

@XmlAccessorType(XmlAccessType.NONE)
public class Foo {

    private Bar bar;

    public Bar getBar() {
        return bar;
    }

    public void setBar(Bar bar) {
        this.bar = bar;
    }

}

并且:

public class Bar {

    public Bar(String name) {
    }

}

EclipseLink MOXy JAXB 实现正在处理 Bar 类,尽管它不应该如此,因为它没有被映射。

I have been able to verify this issue, the following bug has been entered to track this issue.

Issue summary:

For the following object model:

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

@XmlAccessorType(XmlAccessType.NONE)
public class Foo {

    private Bar bar;

    public Bar getBar() {
        return bar;
    }

    public void setBar(Bar bar) {
        this.bar = bar;
    }

}

and:

public class Bar {

    public Bar(String name) {
    }

}

The EclipseLink MOXy JAXB implementation is processing the Bar class although it should not be, because it is not mapped.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文