How to @Autowire objects in Validator classes?

前端 未结 2 1722
有刺的猬
有刺的猬 2021-02-14 06:36

Is it possible to Autowire an object in a Validation class? I keep getting null for the object that is supposed to be Autowired...

2条回答
  •  不知归路
    2021-02-14 06:53

    Trying to follow what you show above, I am still getting a null pointer:

    context.xml:

    
    
    

    AccessRequestValidator.java

    package com.wuntee.taac.validator;
    
    @Component
    public class AccessRequestValidator implements Validator {
    
        @Autowired
        private UserAccessCache userAccessCache;
    ...
    }
    

    business-context.xml:

       
            
            
       
    

    Does the scanner recursively scan the tree?

提交回复
热议问题