在項目的jar中有一個validation.xml包含了Address bean的字段級驗證。javax.validation.ValidationException:已經在xml中配置了%class%
另一個項目使用Address類並需要進行特定的地址驗證。因此,使用Address bean的類級驗證創建了extended-validation.xml。
因此,在應用程序部署期間,ValidationException發生:javax.validation.ValidationException: my.base.datatypes.Address has already be configured in xml.
。
這裏是兩個帶有基本驗證和「擴展驗證」的驗證xml文件。
的validation.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>
擴展的validation.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>
是否有可能擴大現有的驗證?