I have created a few interfaces extending CrudRepository. I'd like to use them into a generic class that is not a bean. What I do currently is to inject them using @Autowired inside my RestController and then pass them down as method arguments to this generic class I'm talking about. Is there a better way to achieve this?
            Asked
            
        
        
            Active
            
        
            Viewed 45 times
        
    0
            
            
         
    
    
        asenovm
        
- 6,397
- 2
- 41
- 52
- 
                    Possible duplicate of [Spring autowiring using @Configurable](http://stackoverflow.com/questions/4703206/spring-autowiring-using-configurable) – hahn Aug 31 '16 at 11:39
1 Answers
1
            
            
        One approach is to make your unmanaged class extending SpringBeanAutowiringSupport and use @Autowired properties. If your application has a Spring web application context, it can then try to get the context from the current thread and resolve the @Autowired properties for you.
 
    
    
        Tommy Siu
        
- 1,265
- 2
- 10
- 24