0

I have a class for HandlerExceptionResolver

@Service
public class GlobalHandlerExceptionResolver implements HandlerExceptionResolver{

    @Override
    public ModelAndView resolveException(HttpServletRequest req, HttpServletResponse resp,Object handler, Exception ex){
        return new ModelAndView("/error", "message","UH OH!!!!");
    }


}

I was told that the package needs to be component scanned, how do I do that?

GreyWolf18
  • 141
  • 1
  • 3
  • 13
  • That depends on how you setup Spring. Is it Spring Boot with Annotations? Regular Spring with some XML configuration? Something else? Did you try searching the web for component scan, i.e. *did you do your **research**?* – Andreas Mar 08 '20 at 18:55
  • @greywolf18 check which package contains spring beans, for that class add "@ComponentScan" – jose praveen Mar 08 '20 at 19:00
  • @JosePraveen how do I tell which packages contain spring beans? is it the imports? – GreyWolf18 Mar 08 '20 at 19:09
  • Please go through [`@ComponentScan`](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/ComponentScan.html#value--) – R.G Mar 09 '20 at 04:31

0 Answers0