JAXB 忽略 XmlElement 指令

发布于 2024-10-10 00:12:28 字数 437 浏览 0 评论 0原文

我在为我所拥有的类生成架构时遇到问题。 我所拥有的是:

@XmlRootElement

@XmlAccessorType(XmlAccessType.FIELD)

public Class User {

....

@XmlElement(required = true)

protected String name;

....

}

现在,当我使用 schemagen 生成模式时,引用该属性的行是:

<xs:element name="name" type="xs:string"/>

缺少 minOcurrences 属性,我不知道为什么它忽略注释,非常感谢任何帮助。 另外,在一个单独且不相关的主题上,当我的类使用 JPA 注释进行注释时,为什么 schemagen 会抱怨?有什么解决方法吗?

I have a problem generating the schema for a class I have.
What I have is:

@XmlRootElement

@XmlAccessorType(XmlAccessType.FIELD)

public Class User {

....

@XmlElement(required = true)

protected String name;

....

}

Now, when I generate the schema using schemagen the line refering to that attribute is:

<xs:element name="name" type="xs:string"/>

the minOcurrences attribute is missing, I don't know why it ignores the annotation, any help is greatly appreciated.
Also on a separate and unrelated topic, why does schemagen complaint when my class is anotated with JPA annotations? Is there any workaround for this?

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

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

发布评论

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

评论(1

黒涩兲箜 2024-10-17 00:12:28

抱歉,我真蠢,minOccur 的默认值是 1。

Sorry, how stupid of me, the default value for minOccur is 1.

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