简体   繁体   English

禁用Spring bean验证

[英]Disable spring bean validation

We are using spring core + struts (without spring MVC) 我们正在使用弹簧芯+支撑杆(没有弹簧MVC)

Also, we are using spring bean validator with hibernate validator feature for realize the design by contract pattern. 另外,我们使用带有休眠验证器功能的spring bean验证器通过契约模式实现设计。

As you know, these validations must be turned of when you deploy your application. 如您所知,在部署应用程序时必须关闭这些验证。

How is it possible to turn off the spring validation is applicationContext.xml? 如何关闭applicationContext.xml的Spring验证?

Method validation in Spring is enabled via configuring a MethodValidationPostProcessor . 通过配置MethodValidationPostProcessor启用S​​pring中的方法验证。 In case you want to turn off method validation in certain scenarios you need to make sure no such processor is configured, eg by configuring it via a bean profile which is not active in this scenario. 如果要在某些情况下关闭方法验证,则需要确保未配置任何此类处理器,例如,通过在此情况下未激活的Bean配置文件对其进行配置。

Method validation is not intended to be used only during development though, I'd recommend to have it enabled in production as well. 尽管方法验证不打算仅在开发期间使用,但我建议在生产中也启用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM