Spring单例注入,单例对象可设置成Spring元件。 只有Spring的元件中@Autowired才有用,在普通类中@Autowired虽然不会编译报错,但运行时会报空指针错误。 转载于:https://www.cnblogs.com/qcxdoit/p/7161104.html