有A、B两个Controller
有C、D两个Service
Controller、Service均是用注解的方式写的,以context:component-scan的方式加载
A、C由ContextLoaderListener加载,B、D由DispatcherServlet加载
运行结果是Controller里只有B有效,访问A会报org.springframework.web.servlet.DispatcherServlet noHandlerFound,但是C、D两个Service都可以正常使用,在B中注入C、D时一切正常。(简单来说就是ContextLoaderListener中加载的Controller无效)
想请教以下问题:
1.都是Controller,为什么ContextLoaderListener加载的controller无效,DispatcherServlet加载controller有效?
2.都是ContextLoaderListener加载的bean,为什么Controller无效,但是别的bean可以正常使用?
3.这是我个人环境或设置的问题,还是spring本来就这么设计的?
4.有什么办法可以让ContextLoaderListener正常加载Controller吗?
麻烦尽量说的详细一点,谢谢。。。