进行bean验证所需的罐子是什么? [英] What are the jars necessary to bean validation?

查看:91
本文介绍了进行bean验证所需的罐子是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用bean验证程序来验证我的bean.问题是我不知道验证需要哪些库.

I'm trying validating my beans using bean validator. The problem is I don't know which libraries(jar) are necessary to validation.

我正在使用.

Vaadin 7,BeanFieldGroup和EclipseLink

Vaadin 7, BeanFieldGroup and EclipseLink

/** class of MyBean */
public class MyBean{
    @Id
@GeneratedValue 
    private Long id;

    @NotNull
    @NotEmpty
    @Size(min=5, max=50, message="Min = 5 and Max = 50, this field is not empty")
    private String name;

    @Email
    @NotEmpty
    private String email; 

}

有什么主意吗?

推荐答案

请遵循有关如何在Eclipse项目中下载和配置Hibernate Validator的这些分步说明:

Follow these step-by-step instructions on how to download and configure Hibernate Validator in your Eclipse project:

  1. 从JBoss存储库下载以下Hibernate Validator文件:
  1. Download the following Hibernate Validator files from JBoss Repository:
    • validation-api-1.1.0.Final.jar
    • validation-api-1.1.0.Final-javadoc.jar
    • validation-api-1.1.0.Final-sources.jar
    • hibernate-validator-5.1.0.Final.jar
    • hibernate-validator-5.1.0.Final-javadoc.jar
    • hibernate-validator-5.1.0.Final-sources.jar
  • 输入您的库名称(即 Hibernate Validator 5.1.0 )
  • 点击确定按钮接受
  • enter your library name (i.e. Hibernate Validator 5.1.0)
  • click OK button to accept
  • 选择以前下载的validation-api-1.1.0.Final.jarhibernate-validator-5.1.0.Final.jar文件
  • 单击打开按钮将其添加到 Hibernate Validator 5.1.0
  • select the previously downloaded validation-api-1.1.0.Final.jar and hibernate-validator-5.1.0.Final.jar files
  • click Open button to add them into Hibernate Validator 5.1.0 library
  • 选择外部位置单选按钮
  • 单击外部文件... 按钮以打开 JAR/ZIP文件选择窗口
  • 选择以前下载的validation-api-1.1.0.Final-sources.jar
  • 单击打开按钮以在父窗口中设置位置路径
  • 点击确定按钮接受
  • select External location radio button
  • click External File... button to open JAR/ZIP File Selection window
  • select the previously downloaded validation-api-1.1.0.Final-sources.jar
  • click Open button to set up Location path in the parent window
  • click OK button to accept
  • 选择存档中的Javadoc 单选按钮
  • 选择外部文件... 单选按钮
  • 点击浏览... 按钮以打开 Javadoc Archice Selection 窗口
  • 选择以前下载的validation-api-1.1.0.Final-javadoc.jar
  • 单击打开按钮以在父窗口中设置存档路径
  • 点击确定按钮接受
  • select Javadoc in archive radio button
  • select External File... radio button
  • click Browse... button to open Javadoc Archice Selection window
  • select the previously downloaded validation-api-1.1.0.Final-javadoc.jar
  • click Open button to set up Archive path in the parent window
  • click OK button to accept

片刻之后,Eclipse准备使用Bean验证约束.

In a moment Eclipse is ready to work with Bean Validation constraints.

实际上,您可以在第5步中结束配置,因为这是使Bean验证工作所需的全部,但是如果给定的主.jar与相应的-javadoc和-sources库相关联,则开发会更加轻松因为它使您有机会:

In fact you could end up the configuration on step 5) as this is all you need to make Bean Validation work, however development is much more comfortable if a given main .jar is associated with its corresponding -javadoc and -sources libraries as it gives you opportunity to:

  • 查看Javadoc注释- F2
  • 查看源文件- F3
  • view Javadoc comments - F2
  • view source files - F3

分别针对Eclipse Java编辑器中的选定约束.

respectively for the selected constraint in Eclipse Java Editor.

现在,想象一下您可以使用Maven一步(很好,几乎)实现相同的目标,但这又是另一回事了……

Now, imagine you can achieve the same with a single step (well, almost) using Maven but that's another story for another time...

这篇关于进行bean验证所需的罐子是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆