@Test(expected = BeanCreationException.class) public void cronTaskWithMethodValidation() throws InterruptedException { BeanDefinition validationDefinition = new RootBeanDefinition(MethodValidationPostProcessor.class); BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class); BeanDefinition targetDefinition = new RootBeanDefinition(CronTestBean.class); context.registerBeanDefinition("methodValidation", validationDefinition); context.registerBeanDefinition("postProcessor", processorDefinition); context.registerBeanDefinition("target", targetDefinition); context.refresh(); }
@Test public void testMethodValidationPostProcessor() { StaticApplicationContext ac = new StaticApplicationContext(); ac.registerSingleton("mvpp", MethodValidationPostProcessor.class); MutablePropertyValues pvs = new MutablePropertyValues(); pvs.add("beforeExistingAdvisors", false); ac.registerSingleton("aapp", AsyncAnnotationBeanPostProcessor.class, pvs); ac.registerSingleton("bean", MyValidBean.class); ac.refresh(); doTestProxyValidation(ac.getBean("bean", MyValidInterface.class)); ac.close(); }
@Bean public MethodValidationPostProcessor methodValidationPostProcessor(Validator validator) { MethodValidationPostProcessor processor = new MethodValidationPostProcessor(); processor.setValidator(validator); return processor; }
@Bean public MethodValidationPostProcessor methodValidationPostProcessor(ConstraintViolationExceptionMapper<?> exceptionMapper) { MethodValidationPostProcessor postProcessor = new CustomMethodValidationPostProcessor(exceptionMapper); postProcessor.setValidator(localValidatorFactoryBean()); return postProcessor; }
@Bean public MethodValidationPostProcessor methodValidationPostProcessor(){ return new MethodValidationPostProcessor(); }
@Bean public MethodValidationPostProcessor methodValidationPostProcessor() { return new MethodValidationPostProcessor(); }
@Bean public BeanPostProcessor methodValidationPostProcessor() { MethodValidationPostProcessor processor = new MethodValidationPostProcessor(); return processor; }
@Bean public MethodValidationPostProcessor methodValidationPostProcessor() throws ClassNotFoundException { MethodValidationPostProcessor processor = new MethodValidationPostProcessor(); processor.setValidator(this.localValidatorFactoryBean()); return processor; }
@Bean public MethodValidationPostProcessor getMethodValidationPostProcessor(Validator validator) { MethodValidationPostProcessor methodValidationPostProcessor = new MethodValidationPostProcessor(); methodValidationPostProcessor.setValidator(validator); return methodValidationPostProcessor; }
@Bean public MethodValidationPostProcessor getMethodValidationPostProcessor() { final MethodValidationPostProcessor processor = new MethodValidationPostProcessor(); processor.setValidator(validator()); return processor; }
/** * 注册bean验证 * @return */ @Bean public MethodValidationPostProcessor methodValidationPostProcessor(){ MethodValidationPostProcessor processor = new MethodValidationPostProcessor(); return processor; }
@Bean public MethodValidationPostProcessor methodValidationPostProcessor() {//用于参数验证 return new MethodValidationPostProcessor(); }
@Bean public MethodValidationPostProcessor methodValidationPostProcessor() {//开启bean验证 return new MethodValidationPostProcessor(); }
@Bean public MethodValidationPostProcessor methodValidationPostProcessor() { MethodValidationPostProcessor processor = new MethodValidationPostProcessor(); processor.setValidator(validator()); return processor; }
@Bean MethodValidationPostProcessor methodValidationPostProcessor() { return new MethodValidationPostProcessor(); }
/** * Defines the validation processor bean. * * @return the {@link MethodValidationPostProcessor} */ @Bean public MethodValidationPostProcessor methodValidationPostProcessor() { return new MethodValidationPostProcessor(); }