13.07.2015 Views

JSR 303 的参考实现使用指南 - JBoss

JSR 303 的参考实现使用指南 - JBoss

JSR 303 的参考实现使用指南 - JBoss

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

第 1 章 开 始 入 门if you are using the SourceForge package you find the necessarylibraries in the lib/jdk5 directory. In case you are not using theXML configuration you can also disable it explicitly by callingConfiguration.ignoreXmlConfiguration() during ValidationFactory creation. Inthis case the JAXB dependencies are not needed.1.1. 第 一 个 Maven 项 目使 用 Maven archetype 插 件 来 创 建 一 个 新 的 Maven 项 目例 1.2. 使 用 Maven archetype 插 件 来 创 建 一 个 简 单 的 基 于 Hibernate Validator的 项 目mvn archetype:generate -DarchetypeGroupId=org.hibernate \-DarchetypeArtifactId=hibernate-validator-quickstart-archetype \-DarchetypeVersion=4.2.0.Final \-DarchetypeRepository=http://repository.jboss.org/nexus/content/groups/public-jboss/ \-DgroupId=com.mycompany \-DartifactId=hv-quickstartMaven 将 会 把 你 的 项 目 创 建 在 hv-quickstart 目 录 中 . 进 入 这 个 目 录 并 且 执 行 :mvn test这 样 , Maven 会 编 译 示 例 代 码 并 且 运 行 单 元 测 试 , 接 下 来 , 让 我 们 看 看 生 成 的 代 码 .注 意From version 4.2.0.Beta2, the maven command mvn archetype:create will beno longer supported and will fail. You should use the command describedin the above listing. If you want more details, look at Maven Archetypeplugin [http://maven.apache.org/archetype/maven-archetype-plugin/] page.1.2. 添 加 约 束在 你 喜 欢 的 IDE 中 打 开 这 个 项 目 中 的 Car 类 :例 1.3. 带 约 束 性 标 注 (annotated with constraints) 的 Car 类package com.mycompany;2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!