在Websphere Application Server 8.5.5上使用bean验证来验证JAX-RS资源和方法(IBM JAX-RS实现) [英] Validating JAX-RS resources and methods (IBM JAX-RS implementation) using bean validation on Websphere Application Server 8.5.5

查看:146
本文介绍了在Websphere Application Server 8.5.5上使用bean验证来验证JAX-RS资源和方法(IBM JAX-RS实现)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IBM JAX-RS实现来开发我的REST API.我希望包括使用JAX-RS 2.0中提供的Bean验证(注释)支持来验证资源方法参数.我知道Jersey的实现支持此功能( https://jersey.java.net/documentation/latest/bean-validation.html ). WAS 8.5.5上的IBM JAX-RS实现是否提供类似的支持?如果可以,请您指导我一些有关如何完成此操作的教程?

我正在特别关注启用和配置Bean验证支持以及它与IBM JAX-RS的集成.

解决方案

是的,WebSphere(传统的和Liberty的)将支持JAX-RS的bean验证.但是我不知道任何教程.您引用的Jersey文档中的代码将与WebSphere的JAX-RS/BV实现一起使用.

要在Liberty中启用JAX-RS和Bean验证,您的server.xml必须包含以下功能:

<featureManager>
  <feature>jaxrs-2.0</feature>
  <feature>beanValidation-1.1</feature>
</featureManager>

作为替代方案,您可以包括一些包含这些功能的功能(例如webProfile-7.0或javaee-7.0,但可能会给您带来比您想要的功能更多的功能).

然后,如果您将应用程序打包为EAR或WAR文件,则可以将其复制到服务器的dropins目录中,启动服务器,并且您应该能够运行示例(默认的HTTP端口为9080)./p>

此链接提供有关在WebSphere Liberty中开发和部署JAX-RS应用程序的其他信息: http://www.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_dep_jaxrs.html

希望这会有所帮助, 安迪

I am using IBM JAX-RS implementation to develop my REST APIs. I am looking to include validation of resource method parameters using Bean Validation (annotations) support provided in JAX-RS 2.0. I know that Jersey implementation supports this feature (https://jersey.java.net/documentation/latest/bean-validation.html). Is there a similar support available with IBM JAX-RS implementation on WAS 8.5.5? If so could you please direct me to some tutorial on how to accomplish this?

I am specifically looking into enabling and configuring Bean Validation support along with its integration with IBM JAX-RS.

解决方案

Yes, WebSphere (both traditional and Liberty) will support bean validation with JAX-RS. But I am not aware of any tutorials. The code in the Jersey document that you referenced will work with WebSphere's JAX-RS/BV implementation.

To enable JAX-RS and Bean Validation in Liberty, your server.xml must contain the following features:

<featureManager>
  <feature>jaxrs-2.0</feature>
  <feature>beanValidation-1.1</feature>
</featureManager>

As an alternative, you could include some feature that includes those features (like webProfile-7.0 or javaee-7.0, but that may get you more function than you want).

Then, if you have your application packaged as an EAR or WAR file, you can copy it into your server's dropins directory, start the server and you should be able to run the example (the default HTTP port is 9080).

This link provides additional information about developing and deploying JAX-RS applications in WebSphere Liberty: http://www.ibm.com/support/knowledgecenter/was_beta_liberty/com.ibm.websphere.wlp.nd.multiplatform.doc/ae/twlp_dep_jaxrs.html

Hope this helps, Andy

这篇关于在Websphere Application Server 8.5.5上使用bean验证来验证JAX-RS资源和方法(IBM JAX-RS实现)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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