2

プロジェクトの jar には Bean 検証があり、validation.xml には Address Bean のフィールドレベルの検証が含まれています。

他のプロジェクトは Address クラスを使用しており、特定の Address 検証が必要です。そのため、アドレス Bean のクラス レベルの検証を使用して、extended-validation.xml が作成されました。

その結果、アプリのデプロイ中に ValidationException が発生します: javax.validation.ValidationException: my.base.datatypes.Address has already be configured in xml..

基本的な検証と「拡張検証」を含む 2 つの検証 xml ファイルを次に示します。

検証.xml

<bean class="my.base.datatypes.Address" ignore-annotations="true">
    <getter name="country">
        <constraint annotation="my.imp.services.validation.ValidCode">
            <message>{msg01}</message>
            <groups>
                <value>my.imp.services.validation.ImportGroup</value>
            </groups>
            <element name="name">Country</element>
        </constraint>
    </getter>
</bean>

拡張検証.xml

<bean class="my.base.datatypes.Address" ignore-annotations="true">
    <class ignore-annotations="true">
        <constraint annotation="my.extended.imp.services.validation.ValidAddress">
            <message>ERROR DURING ADDRESS VALIDATION</message>
            <groups>
                <value>my.imp.services.validation.ImportGroup</value>
            </groups>
        </constraint>
    </class>
</bean>

既存の検証を拡張することは可能ですか?

4

1 に答える 1