//之前都是直接newInstance的到obj,类中的变量无法被注入
//Object obj = aClass.newInstance();
//改成如下方式的到bean,变量就能顺利被注入 ,其他不变
@Autowired
private ApplicationContext context;
Object bean = context.getAutowireCapableBeanFactory()
.createBean(aClass, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true);

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
猜你喜欢
  • 2021-09-20
  • 2021-12-17
  • 2022-12-23
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案