第一步:添加架包

第二步:写一个简单的实列

package com.java.test;

/**
* @author nidegui
* @create 2019-06-22 10:58
*/
public class Helloworld { public void say(){
System.out.println("nihao spring");
}
}

  

第三步:用bean

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="helloWorld" class="com.java.test.Helloworld"></bean> </beans>

  

第四步:测试

package com.java.test;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; /**
* @author nidegui
* @create 2019-06-22 11:00
*/
public class Test {
public static void main(String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml"); //获取bean
Helloworld helloWorld = (Helloworld) ac.getBean("helloWorld"); //获取bean的名字
helloWorld.say();
}
}

  

最新文章

  1. php使用p3p实现cookies跨域设置 实现单点登录,全站登录
  2. 【转】包管理器Bower详细讲解
  3. COJ977 WZJ的数据结构(负二十三)
  4. A beginner’s introduction to Deep Learning
  5. powerdesigner jdbc 连接 oracle
  6. 【转】shell 教程——07 Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数
  7. SZU:B85 Alec&#39;s Eggs
  8. Oracle技术面试问题
  9. java中枚举起别名
  10. 语义化标签和jQuery选择器
  11. IS基础(函数片)
  12. 20165337岳源 预备作业3:Linux安装及命令入门
  13. MVC校验方式【六】
  14. flask框架----flask中的wtforms使用
  15. #JS attr和prop的区别
  16. vivado2015.4 simulator 存储所有信号到 .wdb 文件 并打开波形文件查看波形
  17. module.exports 、 exports 和 export 、 export default 、 import
  18. Spring Boot构建RESTful API
  19. What is Continuous Integration?
  20. Android系统移植与调试之------->MTK 标准编译命令

热门文章

  1. sql中对数值四舍五入取小数点后两位数字
  2. 开启mysql远程连接
  3. mybatis sql语句#{}和${}区别联系
  4. 学习C#和SQL的书籍
  5. Android图片异步载入框架Android-Universal-Image-Loader
  6. 2.5-冗余VLAN
  7. android.os.Process.killProcess(android.os.Process.myPid())与Activity生命周期的影响
  8. poi读写Excel
  9. [Contest Hunter#17-C] 舞动的夜晚
  10. js定义类和方法