1.@Resource(重要)
a)加入 :j2ee/common-annotations.jar
b)默认按名称,名称找不到,按类型

默认按照名称setName1到xml中找和id相同的,没有的话再找和SetName类型一样的

public class HelloWorld {
SetName setName;
@Resource
public void setMessage(SetName setName1){
this.setName=setName1;
System.out.println("setmessage");
setName1.getSetName() ;
}
}
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <context:annotation-config/>
<bean id="helloWorld" class="com.yibai.HelloWorld">
<!-- <property name="message" value="Hello World!"/> -->
</bean>
<bean id="setName1" class="com.yibai.SetName">
</bean>
<bean id="setname12" class="com.yibai.SetName">
</bean>
</beans>

最新文章

  1. 【代码笔记】iOS-获得现在的日期
  2. VirtualBox安装MS-DOS6.22(图文教程)
  3. 识别 Linux上的设备(磁盘)类型
  4. PHP面向对象讲解
  5. 关于webapp的一点思考
  6. Apache+MySQL+PHP开发环境的搭建(一)
  7. iOS 宏(define)与常量(const)的正确使用
  8. strstr 函数用法
  9. RX学习笔记:正则表达式
  10. mysql学习笔记4---mysql 复制---源代码
  11. [QT]Qt+VS2012+Win8 64Bit安装
  12. 普通Java程序员学习使用的6个JDK内建工具
  13. 字符串(后缀自动机):Codeforces Round #129 (Div. 1) E.Little Elephant and Strings
  14. Rabbitmq 性能测试
  15. python写zip破解器
  16. python语法_str_eval
  17. CF Manthan, Codefest 16 B. A Trivial Problem
  18. LeetCode(99):恢复二叉搜索树
  19. [20171225]没有备份数据文件的恢复.txt
  20. arguments.callee 和 caller

热门文章

  1. web 文件下载
  2. 九度OJ 1193:矩阵转置 (矩阵计算)
  3. 1.Python学习---helloworld
  4. 将本地jar包手动复制到Maven库中,在其它电脑上用Maven打包时出错
  5. [Java面试一]Spring总结以及在面试中的一些问题.(转发:http://www.cnblogs.com/wang-meng/p/5701982.html)
  6. php......调研投票练习
  7. 每天一个Linux命令(32)date命令
  8. DEV开发之汉化
  9. 【leetcode刷题笔记】Simplify Path
  10. 第二十一篇 socket