在写Controller层方法时,将方法标记为 private
,成员变量通过 @Autowired
注入,结果调用该方法时因代理失效导致依赖对象为 null
需将方法/字段改为 public
确保需要依赖注入的方法或字段的访问修饰符为 public
,使其能被 Spring 代理覆盖
在写Controller层方法时,将方法标记为 private
,成员变量通过 @Autowired
注入,结果调用该方法时因代理失效导致依赖对象为 null
需将方法/字段改为 public
确保需要依赖注入的方法或字段的访问修饰符为 public
,使其能被 Spring 代理覆盖