有没有办法将JSR303-annotations添加到cxf生成的类中? [英] Is there a way to add JSR303-annotations to cxf-generated classes?

查看:55
本文介绍了有没有办法将JSR303-annotations添加到cxf生成的类中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题可能说了这一切,我想知道是否可以告诉cxf-codegen-plugin添加,例如,xsd-patterns为 @Pattern 注释。模式验证很好,但有时我只是想检查单个元素而不是无数无数的xml行。

The title probably said it all, I was wondering if one could tell the cxf-codegen-plugin to add, for example, the xsd-patterns as @Pattern annotations. Schema validation is nice and all, but sometimes I just want to check a single element and not endless myriads of xml lines.

因此我想知道是否有诀窍/选项/脏黑客那里可以帮助我转动

Therefor I was wondering if there is a trick / option / dirty hack out there that would help me turning

<xs:simpleType name="string2000">
    <xs:restriction base="xs:string">
        <xs:maxLength value="2000"/>
        <xs:minLength value="1"/>
        <xs:pattern value="[\p{IsBasicLatin}\p{IsLatin-1Supplement}-[ \t\r\n]][\p{IsBasicLatin}\p{IsLatin-1Supplement}-[\t\r\n]]*"/>
    </xs:restriction>
</xs:simpleType>

进入

@Pattern(regexp = "\\p{IsBasicLatin}\\p{IsLatin-1Supplement}-[ \\t\\r\\n]][\\p{IsBasicLatin}\\p{IsLatin-1Supplement}-[\\t\\r\\n]]*")
@Size(min = 1, max = 2000)

因为手动添加它是一个禁止使用此数量的xml,它会真的让事情变得更轻松。

since adding it manually is a no-go with this amount of xml, and it would really make things easier.

推荐答案

我对cxf-codegen-plugin没有直接经验,但我也需要包括 @Pattern @Size ,以及其他< xs:restriction /> 从XSD派生到我的JAXB生成的类中的注释,最后使用krasa-jaxb-tool来实现这一点。

I have no direct experience with the cxf-codegen-plugin but, I too had a need to include @Pattern, @Size, and other <xs:restriction /> annotations derived from XSDs into my JAXB generated classes and ended up using the krasa-jaxb-tool which does just this.

参见包括-xsrestrictions-as-annotations-in-moxy-generated-java-classes

这篇关于有没有办法将JSR303-annotations添加到cxf生成的类中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆