
正文
Spring动态获取已注入的对象的方法
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
1、根据类获取对象
@Autowired
ApplicationContext context; GenericMapper<T,String> dao=(GenericMapper<T,String>)context.getBean(TestDaoImpl.class);
2、根据接口获取实现类的对象
@Autowired
ApplicationContext context; GenericMapper<T,String> dao=(GenericMapper<T,String>)context.getBean(TestInterface.class);






