问题遇到的现象和发生背景
浏览器一直500报错 HTTP Status 500 - Servlet.init() for servlet DispatcherServlet threw exception
Error creating bean with name 'demoController': Unsatisfied dependency expressed through field 'demoService'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.hjbnb.service.DemoService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
问题相关代码,请勿粘贴截图
@Controller
public class DemoController {
@Autowired
private DemoService demoService;
@RequestMapping(value = "/show")
public String show() throws FileNotFoundException, MyException {
System.out.println("show running......");
//demoService.show1();
//demoService.show2();
//demoService.show3();
//demoService.show4();
demoService.show5();
return "index";
}
}