Java tutorial
/* * Copyright (c) 2014, the original author or authors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * A copy of the GNU General Public License accompanies this software, * and is also available at http://www.gnu.org/licenses. */ package name.abhijitsarkar.javaee.coffeehouse.spring; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; /** * @author Abhijit Sarkar */ @Configuration @ComponentScan(basePackageClasses = { SpringPackageComponentScanMarker.class }) @EnableAspectJAutoProxy public abstract class AppConfig { @Bean public MethodValidationPostProcessor methodValidationPostProcessor() { final MethodValidationPostProcessor methodValidationPostProcessor = new MethodValidationPostProcessor(); methodValidationPostProcessor.setValidator(validator()); return methodValidationPostProcessor; } @Bean public LocalValidatorFactoryBean validator() { final LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean(); return localValidatorFactoryBean; } }