paip.spring 获取bean  getBean 没有beanid的情况下





spring能自动扫描带有注解的bean文件..





作者Attilax  艾龙,  EMAIL:1466519819@qq.com 

来源:attilax的专栏

地址:http://blog.csdn.net/attilax





设置

    <context:annotation-config />

<context:component-scan base-package="com.mijie.homi.search.dao.**"/>

<context:component-scan base-package="com.mijie.homi.search.service.**"/> 

这个时候儿,没有beanid在app.xml以及java文件中...

默认那是class名称,第一的字母小写..MoodUserIndexService.java >>>>   moodUserIndexService





ApplicationContext act=new FileSystemXmlApplicationContext("classpath:applicationContext.xml"); 

MoodUserIndexService moodUserService=  (MoodUserIndexService) act.getBean("moodUserIndexService"); 





参考

在应用程序中怎么自动加载Spring,并注入sessionFactory - ITeye问答.htm

Spring@Autowired注解与自动装配 - - 博客频道 - CSDN.NET.htm

Spring注解@Componen、@Repository@Service、@Controller区别 - 豆丁网.htm

paip.spring 获取bean getBean 没有beanid的情况下的更多相关文章

  1. Spring获取bean的几种方式

    工作中需要对一个原本加载属性文件的工具类修改成对数据库的操作当然,ado层已经写好,但是需要从Spring中获取bean,然而,工具类并没有交给Spring来管理,所以需要通过方法获取所需要的bean ...

  2. spring获取bean的时候严格区分大小写

    如题:spring获取bean的时候严格区分大小写 配置文件helloservice.xml中配置: <dubbo:reference id="IInsurance" int ...

  3. Spring获取bean工具类,可用于在线程里面获取bean

    Spring获取bean工具类,可用于在线程里面获取bean import java.util.Locale; import org.springframework.beans.BeansExcept ...

  4. 关于spring获取webApplication.getBean多种途径和简单解释

    ApplicationContext ac1 = new FileSystemXmlApplicationContext("com/spark/system/applicationConte ...

  5. Spring获取bean的一种方式

    随便一百度,网上一大把,并且还不止一种.所以这里就只记录目前用的一种好了. 实现ApplicationContextAware接口 即可: import org.springframework.bea ...

  6. Spring 获取bean

    方法一: ApplicationContext ap = new ClassPathXmlApplicationContext("applicationContext.xml"); ...

  7. spring 获取 bean

    不通过注解或者是配置文件怎么获取spring中定义的bean呢?有几个方法: 1.实现ApplicationContextAware <bean class="com.xxx.Spri ...

  8. Spring获取bean的工具类

    package com.tech.jin.util; import org.springframework.context.ApplicationContext; import org.springf ...

  9. Spring获取bean的步骤

    1 处理&问题 2 去chache里找 3 处理对象A依赖对象B的问题 4 生成bean   4.1 处理方法注入 ------lookup-method   4.2 如果类实现了Instan ...

随机推荐

  1. 设置input 内容居中显示 .

    text-align:center  水平居中显示 <style type="text/css"> input.text{text-align:center;paddi ...

  2. storyboard xib下label怎么自适应宽度高度

    先看需求:两个Label,要求蓝色的label紧跟在红色的label文字后面  ok首选正常添加约束 红色的Label添加宽度,高度,左边,上边约束 蓝色的Label添加宽度,高度,左边,和红色的水平 ...

  3. codevs 2756树上的路径

    题意: 2756 树上的路径  时间限制: 3 s  空间限制: 128000 KB  题目等级 : 大师 Master    题目描述 Description 给出一棵树,求出最小的k,使得,且在树 ...

  4. Swift3.0基础语法学习<五>

    异常处理: // // ViewController5.swift // SwiftBasicDemo // // Created by 思 彭 on 16/11/16. // Copyright © ...

  5. 卸载Oracle步骤

    卸载Oracle步骤:1.停止所有与ORACLE相关的服务.2. 使用OUI(Oracle Universal Installer)卸载Oracle软件.   “开始”->“程序”->“O ...

  6. OA项目之导入

    内容显示页: protected void btnIMP_Click(object sender, EventArgs e)         {             Response.Redire ...

  7. 2016中国大学生程序设计竞赛(长春)-重现赛 1010Ugly Problem 回文数 模拟

    Ugly Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  8. JDBC常用接口详解

    JDBC中常用接口详解 ***DriverManager 第一.注册驱动 第一种方式:DriverManager.registerDriver(new com.mysql.jdbc.Driver()) ...

  9. css之字体设置

    字体大小font-size 字体风格font-style 字体加粗font-weight 字体类型font-family 字体阴影text-shadow 字体行高line-height 字间距lett ...

  10. JS延时提示框

    p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 31.0px Consolas; color: #2b7ec3 } p.p2 { margin: 0.0px ...