栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

spring究极复习笔记

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

spring究极复习笔记

第一章 初始spring 1.1 spring 简介
  • spring是一个为简化企业级开发而生的开源框架
  • spring是ioc和aop容器的框架
    •   ioc全称: Inversion Of Control【控制反转】
      • 将对象的控制权由程序员交给spring容器
  •        DI全称:Dependency Injection【依赖注入】  
    • spring管理对象与对象之间的依赖
  •  aop全称: Aspect-Oriented Programming【面向切面编程】 
  • 官网 :Spring | Home
  • spring简介图

1.2 搭建spring环境
  1. 导入jar包
    
        org.springframework
        spring-context
        5.3.1
    
    
    
        junit
        junit
        4.12
        test
    

  2. 创建POJO
     

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    public class Employee {
        private Integer id;
        private String lastName;
        private String email;
        private Double salary;
        private Dept dept;

  3. 编写核心配置文件
       配置文件名字applicationContext.xml【beans.xml或spring.xml】
      位置在src/main/resources
      实例代码
     

        
            
            
            
            
        
    

  4. 使用核心类库【容器对象】

    @Test
    public void testSpringHw(){
        //创建Spring容器对象
        ApplicationContext ioc =
                new ClassPathXmlApplicationContext("applicationContext.xml");
    
        //通过容器对象,获取需要对象
        Employee empCui = (Employee) ioc.getBean("emp2");
        System.out.println("empCui = " + empCui);
    
    }


     

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/821855.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号