Мне нужно автоматически подключить @Service внутри javax.servlet.Filter.
public class CORSFilter implements Filter {
@Autowired
AccessLogService accessLogService;
public void setAccessLogService(AccessLogService accessLogService) {
this.accessLogService = accessLogService;
}
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
// save an access log to the database...
AccessLogDTO rld = new AccessLogDTO( req );
accessLogService.addAccessLog( rld ); // <<<--- NPE here!
// and do other stuff not related to the question...
}
}
, но я получаю ошибку NullPointerException.
@Service
public class AccessLogServiceImpl implements AccessLogService {
// ordinary not special service class.
}