zoukankan      html  css  js  c++  java
  • paip.spring 获取bean getBean 没有beanid的情况下

    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



  • 相关阅读:
    ajax post 数组
    Hello 2018 ABC
    A. The Way to Home
    Codeforces Round #453 (Div. 2) ABC
    Codeforces Round #452 (Div. 2) D
    Codeforces Round #452 (Div. 2) ABC
    Python 常用技巧
    Codeforces Round #451 (Div. 2) E
    Codeforces Round #451 (Div. 2) D. Alarm Clock
    Codeforces Round #451 (Div. 2) ABC
  • 原文地址:https://www.cnblogs.com/attilax/p/5964126.html
Copyright © 2011-2022 走看看