1.Autowire注入到一个类的时候,idea报错说找不到这个类的Bean,但是项目是正常运行的,因为我们使用的是mybatis自动扫描。修改一下idea配置就可以了。
inspections -- Spring -- Spring Core --Code --Autowiring for Bean Class
把 error 改成 warning ,就可以了。
另外在编码时也要注意,不仅仅是在 controller 中 @Autowired 就行了,还应检查 impl 中有没有加上 @Service 注解,曾经有一次就是在这个地方卡住了。
@Controller @RequestMapping("/user/") public class UserController { @Autowired private IUserService iUserService;
@Service("iUserService") //与 IUserService 保持一致 public class UserServiceImpl implements IUserService {}
2.启用实时编译,在下方显示 problems 窗口
Compiler -- Make project automatically (Build project automatically),勾上