Using @Autowired with AspectJ and Springboot
问题 I want to use @Autowired annotation into an "Aspect". I want to inject a repository in my aspect but when I try to call a method of my autowired class a NullPointException occurs. @Aspect public class AspectSecurity { @Autowired private UserRepository userRepository; @After("execution(public * dash.*.*Controller.*(..))") public void authentication(JoinPoint jp) throws UnauthorizedException { System.out.println("SECURITY !"); System.out.println(userRepository.findAll().toString()); } } I have