发布网友
共3个回答
热心网友
不用配置xml,直接java代码实现,参考代码如下:
public class GetApplicationContext {获取所有spring自动装配的bean:
<span style="font-size:18px;">//获取spring装配的bean个数然后通过下面的代码获取到spring注解装配的bean供自己使用:
<span style="font-size:18px;">StorageReturnService ossService = (StorageReturnService) GetApplicationContext.getInstance().getBean("storageReturnServiceImpl");</span>
热心网友
applicationcontext
热心网友
WebApplicationContext.getBean(beanName) 具体用法可以百度一下,很多很详细
热心网友
不用配置xml,直接java代码实现,参考代码如下:
public class GetApplicationContext {获取所有spring自动装配的bean:
<span style="font-size:18px;">//获取spring装配的bean个数然后通过下面的代码获取到spring注解装配的bean供自己使用:
<span style="font-size:18px;">StorageReturnService ossService = (StorageReturnService) GetApplicationContext.getInstance().getBean("storageReturnServiceImpl");</span>
热心网友
applicationcontext
热心网友
WebApplicationContext.getBean(beanName) 具体用法可以百度一下,很多很详细