Java @未验证@NotNull构造函数字段
我试图使用Oval1.84来绕过一些没有样板的验证约束。当我用@NotNull javax.validation.constraint和net.sf.oval.validator标记字段时,验证工作正常Java @未验证@NotNull构造函数字段,java,bean-validation,oval,Java,Bean Validation,Oval,我试图使用Oval1.84来绕过一些没有样板的验证约束。当我用@NotNull javax.validation.constraint和net.sf.oval.validator标记字段时,验证工作正常 但在将常量实现为方法和构造函数参数的情况下不起作用 参数验证需要使用某种方法调用拦截字节码。OVal为AspectJ和SpringAOP提供了现成的实现 使用AspectJ 关于如何将其与AspectJ一起使用,请参见 使用Spring AOP SpringAOP的用法在下面的测试用例中进行了概
但在将常量实现为方法和构造函数参数的情况下不起作用 参数验证需要使用某种方法调用拦截字节码。OVal为AspectJ和SpringAOP提供了现成的实现 使用AspectJ 关于如何将其与AspectJ一起使用,请参见 使用Spring AOP SpringAOP的用法在下面的测试用例中进行了概述 在Spring中,您需要配置要进行方法参数验证的bean,例如:
<bean id="myService" class="com.example.MyService" />
和一个调用拦截器:
<bean id="ovalGuardInterceptor" class="net.sf.oval.guard.GuardInterceptor" />
<bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="proxyTargetClass" value="false" />
<property name="interceptorNames">
<list>
<value>ovalGuardInterceptor</value>
</list>
</property>
<!-- the next line tells which beans you want to use validation for -->
<property name="beanNames" value="myService" />
</bean>
我知道这是一个老问题,但我想我在这里发布的答案是:如果有人看到这篇文章,可能会有所帮助。