我刚刚更新了我的POM以使用Hibernate Validator 5.2.2Final。我们之前使用的是4.2.0Final版本。我必须为5.2.2Final版本进行如下代码更改(也可在此处找到 - http://in.relation.to/2015/09/29/hibernate-validator-522-released/):
HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
ConstraintMapping constraintMapping = new ConstraintMapping;
更改为:
HibernateValidatorConfiguration configuration = Validation.byProvider(HibernateValidator.class).configure();
ConstraintMapping constraintMapping = configuration.createConstraintMapping();
我检查了所有Referenced Libraries和Maven Dependencies,我只在Maven中看到5.2.2Final.jar文件。我没有看到任何对4.2.0Final版本的引用。当我使用这个JAR在Hadoop中运行我的工作时,我收到了这个错误:
2016-02-12 10:18:15,285致命[main] org.apache.hadoop.mapred.YarnChild:运行child时出错:java.lang.NoSuchMethodError:org.hibernate.validator.HibernateValidatorConfiguration.createConstraintMapping( )Lorg /休眠/验证/ cfg中/ ConstraintMapping; java.lang.NoSuchMethodError:org.hibernate.validator.HibernateValidatorConfiguration.createConstraintMapping()Lorg / hibernate / validator / cfg / ConstraintMapping;
我在线搜索但找不到任何东西。此外,Hibernate Validator的文档站点已关闭。我确实使用了Java Decompiler,我看到了:
public abstract interface HibernateValidatorConfiguration
extends Configuration<HibernateValidatorConfiguration>
{
public static final String FAIL_FAST = "hibernate.validator.fail_fast";
public static final String VALIDATED_VALUE_HANDLERS = "hibernate.validator.validated_value_handlers";
public static final String CONSTRAINT_DEFINITION_CONTRIBUTORS = "hibernate.validator.constraint_definition_contributors";
public static final String CONSTRAINT_MAPPING_CONTRIBUTOR = "hibernate.validator.constraint_mapping_contributor";
public static final String TIME_PROVIDER = "hibernate.validator.time_provider";
public abstract ResourceBundleLocator getDefaultResourceBundleLocator();
public abstract ConstraintMapping createConstraintMapping();
public abstract HibernateValidatorConfiguration addMapping(ConstraintMapping paramConstraintMapping);
public abstract HibernateValidatorConfiguration failFast(boolean paramBoolean);
public abstract HibernateValidatorConfiguration addValidatedValueHandler(ValidatedValueUnwrapper<?> paramValidatedValueUnwrapper);
public abstract ConstraintDefinitionContributor getDefaultConstraintDefinitionContributor();
public abstract HibernateValidatorConfiguration addConstraintDefinitionContributor(ConstraintDefinitionContributor paramConstraintDefinitionContributor);
public abstract HibernateValidatorConfiguration externalClassLoader(ClassLoader paramClassLoader);
public abstract HibernateValidatorConfiguration timeProvider(TimeProvider paramTimeProvider);
}
public abstract interface ConstraintMapping
{
public abstract <C> TypeConstraintMappingContext<C> type(Class<C> paramClass);
}
任何帮助都将受到高度赞赏!谢谢!