Spring入门
来源:互联网 发布:ubuntu如何卸载samba 编辑:程序博客网 时间:2024/06/10 01:44
1.Spring 起承上启下作用(web和数据层)
2.Spring 的核心:控制反转(Ioc)、面向切向(AOP)
3.核心容器:beans、core、context、 expression
4.导jar包:4核心,1依赖
4核心:beans、core、context、expression;1依赖logging
5.配置文件:
- 位置:任意,开发一般都在classpath下(src)
- 名称:任意,开发一般都用 applicationContext.xml
- 内容:添加 schema约束 约束文件位置:spring-framework-3.2.0.RELEASE-dist.zip\spring-framework-3.2.0.RELEASE\docs\spring-framework-reference\html\xsd-config.html
- 配置service:<bean>配置需要配置的对象;id:为bean命名,唯一;class:bean的全限定类名
- // 从Spring容器中获得
//1.获得容器
String xmlPath="com/xdq/a_ioc/beans.xml";
ApplicationContext applicationContext=new ClassPathXmlApplicationContext(xmlPath);
//2.获得内容,不需要new,都是从Spring容器中获取
UserService userService=(UserService) applicationContext.getBean("userService");
userService.addUser();
5.DI 依赖注入
is a :是一个,继承
has a :有一个,引用成员变量,依赖
eg;
class A{
private B b;//A类依赖B类
}
依赖:一个类需要使用另一个类
0 0
- Spring 入门
- Spring 入门
- Spring 入门
- Spring入门
- Spring入门
- Spring入门
- Spring入门
- Spring 入门
- spring 入门
- Spring入门
- Spring入门
- Spring入门
- Spring入门
- spring入门
- Spring入门
- spring 入门
- Spring入门
- Spring入门
- [转帖]易飞9.0.9注册机
- 闲谈System.nanoTime()函数
- Spring中的定时任务
- 学好Python的优秀资源推荐
- 【数据结构】数据结构C语言的实现【图(邻接表法)】
- Spring入门
- 【leetcode】63. Unique Paths II【java】
- 将Excel表格中的数据导出到xml文件中
- 互联网公司产品经理们面试的终极攻略
- 【leetcode】64. Minimum Path Sum【java】
- 第十二章—PopupWindow
- JAVA观察者模式
- 向android studio导入android源生app
- 数据库导出到EXAL 再供用户下载