osc*_*car 3 java validation spring hibernate spring-data
我想在特定方法中禁用hibernate验证.例如,保存正常保存的验证并禁用它们以saveWithoutValidation方法.是否可以使用一些注释来执行此操作?
我知道可以在具有属性的配置中禁用它:
<Validation-mode> NONE </ validation-mode>
Run Code Online (Sandbox Code Playgroud)
我真的只是使用带有@Valid注释的控制器上的验证来表示错误.要插入数据库,我不需要.
我的有效解决方案
LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
...
Properties jpaProperties = new Properties();
jpaProperties.put("javax.persistence.validation.mode", "NONE");
factory.setJpaProperties(jpaProperties);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
525 次 |
| 最近记录: |