用Annotations 给类或者类的属性加上约束(constraint),在运行期检查属性值是很优雅的.Hibernate Validator就是这样的一个框架.该框架是十分容易的(就像参考文档中宣称的那样),几乎没有什么学习曲线,Validator 是一个验证框架 不需要和Hibernate的其他部分绑定就可以使用,只要在你的项目中添加Hibernate-annotations.jar库就可以了.
Hibernate Validator 4.3.0.Final 已经发布了,可通过 JBoss Maven Repository (org.hibernate:hibernate-validator:4.3.0.Final ) 或者 SourceForge 获取.
该版本没有包含太多变化,值得关注的有如下几个方面,详情请看:changelog
- The package structure got refactored to separate clearly between API, SPI and internal classes. Doing though we deprecated some classes. Make sure to migrate to the new types when upgrading to 4.3 read more
- slf4j got replaced by JBoss Logging as the main logging framework read more
- A bunch of new and improved constraints, e.g. MOD11, CNPJ, CPF and TituloEleitoral read more
- A bunch of performance and quality improvements, in particular we addressed issues around metadata caching read more
- The Hibernate Validator Annotation Processor can now be used without any additional dependencies which makes it setup easier read more
- Hibernate Validator 4.3 requires now a Java 6 or 7 runtime
Hibernate Validator 的详细介绍:请点这里
Hibernate Validator 的下载地址:请点这里
