SSM开发,使用springMVC框架中自带的spring验证框架来验证数据,编写了一个org.springframework.validation.Validator接口的验证器类SignUpValidator来对领域数据进行验证时,报了以下错误:
“org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userController’: Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘org.springframework.validation.Validator’ available: expected single matching bean but found 2: signUpValidator,org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0”
“org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘org.springframework.validation.Validator’ available: expected single matching bean but found 2: signUpValidator,org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean#0”
看样子是系统不知道引用那个类的意思。
用@Autowired,@Qualifier(value=""),value为该属性用@Commponent(value="")中value的值