spring实现helloWord
2024-09-12 08:34:20
第一步:添加架包
第二步:写一个简单的实列
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();
}
}
最新文章
- php使用p3p实现cookies跨域设置 实现单点登录,全站登录
- 【转】包管理器Bower详细讲解
- COJ977 WZJ的数据结构(负二十三)
- A beginner’s introduction to Deep Learning
- powerdesigner jdbc 连接 oracle
- 【转】shell 教程——07 Shell特殊变量:Shell $0, $#, $*, $@, $?, $$和命令行参数
- SZU:B85 Alec&#39;s Eggs
- Oracle技术面试问题
- java中枚举起别名
- 语义化标签和jQuery选择器
- IS基础(函数片)
- 20165337岳源 预备作业3:Linux安装及命令入门
- MVC校验方式【六】
- flask框架----flask中的wtforms使用
- #JS attr和prop的区别
- vivado2015.4 simulator 存储所有信号到 .wdb 文件 并打开波形文件查看波形
- module.exports 、 exports 和 export 、 export default 、 import
- Spring Boot构建RESTful API
- What is Continuous Integration?
- Android系统移植与调试之------->MTK 标准编译命令
热门文章
- sql中对数值四舍五入取小数点后两位数字
- 开启mysql远程连接
- mybatis sql语句#{}和${}区别联系
- 学习C#和SQL的书籍
- Android图片异步载入框架Android-Universal-Image-Loader
- 2.5-冗余VLAN
- android.os.Process.killProcess(android.os.Process.myPid())与Activity生命周期的影响
- poi读写Excel
- [Contest Hunter#17-C] 舞动的夜晚
- js定义类和方法