applicationContext.getBean(“loginEntity”)

 

<!-- 指定Spring需要扫描的包,并将所有是别的类放到容器中,便于识别被注解的受托管bean -->

<context:component-scan base-package="com.sgfm"
scoped-proxy="interfaces">
<context:exclude-filter type="regex"
expression="com.sgfm.base.jms.demo.*" />    <!--扫描这个包下的所有的bean  bean的类型包括@contorller @entity  @service -->
</context:component-scan>

//获取某个bean的通过类名首字母小写

eg: 

 IndexAction action = (IndexAction) app.getBean("indexAction");

 

posted @ 2017-08-18 14:53  zero_and_one  阅读(346)  评论(0编辑  收藏  举报