1.springIOC常用的注解
2.案例使用xml方式和注解方式实现表单的CRUD操作
3.改造基于注解的IOC案例,使用注解的方式实现
4.spring和Juit的整合

/*** 用于创建对象的注解*/
package com.test;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;public class Test{public static void main(String[] args){//1.获取核心容器对象ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");//2.根据id获取bean对象IAccountService as = (IAccountService)ac.getBean("accountService");System.out.println(as);IAccountDao adao = (IAccountDao)ac.getBean("accountDao");System.out.println(adao);as.saveAccount();}
}interface IAccountService{/*** 模拟保存账户*/public void saveAccount();
}/*** 业务层实现类* 曾经的配置<bean id="accountService" class="com.test.AccountServiceImp"*       scope="" init-method=" " destroy-method="">*        <property name="" value="" ref=""></property>* </bean>** 用于创建对象的注解* 用于注入数据的注解* 用于改变作用范围的注解* 和生命周期相关的* *  @Component*    作用:用于把当前类对象存入spring容器*   属性:*         value:用于指定bean的id,默认值时当前类名首字母改小写*  @Controller  表现层*  @Service     业务层*  @Repository  持久层*/
@Component(value="accountService")
class AccountServiceImp implements IAccountService{public AccountServiceImp(){System.out.println("对象创建了");}public void saveAccount(){IAccountDao adao = new accountDaoImp();adao.saveAccount();}
}interface IAccountDao{public void saveAccount();
}@Repository("accountDao")
class accountDaoImp implements IAccountDao{public void saveAccount(){System.out.println("save a account");}
}

2020-3-25 11:26:14 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1ef9f1d: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1ef9f1d]; startup date [Wed Mar 25 11:26:14 CST 2020]; root of context hierarchy 2020-3-25 11:26:14 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [bean.xml] 2020-3-25 11:26:14 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory 信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@1ef9f1d]: org.springframework.beans.factory.support.DefaultListableBeanFactory@453807 2020-3-25 11:26:14 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@453807: defining beans [accountDao,accountService,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor]; root of factory hierarchy

对象创建了
com.test.AccountServiceImp@e06940
com.test.accountDaoImp@11e0c13
save a account

/*** 用于注入数据的注解*/
package com.test;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;public class Test{public static void main(String[] args){//1.获取核心容器对象ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml");//2.根据id获取bean对象IAccountService as = (IAccountService)ac.getBean("accountService");System.out.println(as);IAccountDao adao = (IAccountDao)ac.getBean("accountDao");System.out.println(adao);as.saveAccount();}
}interface IAccountService{/*** 模拟保存账户*/public void saveAccount();
}/*** 业务层实现类* 曾经的配置<bean id="accountService" class="com.test.AccountServiceImp"*       scope="" init-method=" " destroy-method="">*        <property name="" value="" ref=""></property>* </bean>** 用于创建对象的注解* 用于注入数据的注解*       Autowired*          作用:自动按照类型注入,set方法就不是必要的*         Qualifyer*          在按照类型注入的基础上,按照名称注入*      Resource *          按照名称注入* * 用于注入基本数据类型的注解*        Value,可以使用spring中的SpEL ${}* 用于改变作用范围的注解*        Scope,用于指定bean的作用范围* 和生命周期相关的*       Predestory:用于指定销毁方法*         PostConstructor 用于指定初始化方法*/
@Component(value="accountService")
class AccountServiceImp implements IAccountService{//  @Autowired
//  @Qualifier("accountDao")//该spring版本没有没有@Resource注解private IAccountDao accountDao; //accountDao和容器寸的key相同public AccountServiceImp(){System.out.println("对象创建了");}public void saveAccount(){accountDao.saveAccount();}
}interface IAccountDao{public void saveAccount();
}@Repository("accountDao")
class accountDaoImp implements IAccountDao{public void saveAccount(){System.out.println("save a account");}
}

2020-3-25 11:31:22 org.springframework.context.support.AbstractApplicationContext prepareRefresh 信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@1ef9f1d: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1ef9f1d]; startup date [Wed Mar 25 11:31:22 CST 2020]; root of context hierarchy 2020-3-25 11:31:23 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 信息: Loading XML bean definitions from class path resource [bean.xml] 2020-3-25 11:31:23 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory 信息: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@1ef9f1d]: org.springframework.beans.factory.support.DefaultListableBeanFactory@618d26 2020-3-25 11:31:23 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@618d26: defining beans [accountDao,accountService,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor]; root of factory hierarchy 对象创建了 com.test.AccountServiceImp@1a68ef9 com.test.accountDaoImp@1f48262 save a account

spring5.0学习笔记5相关推荐

  1. mysql5.0镜像_Mysql5.0学习笔记(一)

    Mysql5.0学习笔记(一) -基本sql语句与支持字符集 1.登录 mysql -h localhost -u root 2.创建用户firstdb(密码firstdb)和数据库,并赋予权限于fi ...

  2. Zabbx6.0(学习笔记)

    Zabbx6.0(学习笔记) 目录导航 Zabbx6.0(学习笔记) 一.为什么 需要监控系统 二.如何选择监控 三.Zabbix概述 四.Zabbix安装哪个版本? Zabbix安装要求 1.硬件 ...

  3. flink1.12.0学习笔记第2篇-流批一体API

    flink1.12.0学习笔记第 2 篇-流批一体API flink1.12.0学习笔记第1篇-部署与入门 flink1.12.0学习笔记第2篇-流批一体API flink1.12.0学习笔记第3篇- ...

  4. CCC3.0学习笔记_认证和隐私保护

    CCC3.0学习笔记_Authentication and Privacy Keys 系列文章目录 文章目录 系列文章目录 前言 1. 手机端和车厂服务器端的密钥存储 2. 密钥的产生和使用的说明 3 ...

  5. TensorFlow2.0 学习笔记(三):卷积神经网络(CNN)

    欢迎关注WX公众号:[程序员管小亮] 专栏--TensorFlow学习笔记 文章目录 欢迎关注WX公众号:[程序员管小亮] 专栏--TensorFlow学习笔记 一.神经网络的基本单位:神经元 二.卷 ...

  6. 《TP5.0学习笔记---配置篇》

    TP5.0学习笔记 TP5目录结构介绍 application目录是应用目录,我们整个应用所有的内容都写在这个目录中,在后续开发中,我们更多的时候都是在编写这个目录中的文件.在它里边有一个index文 ...

  7. Tensorflow2.0学习笔记(一)

    Tensorflow2.0学习笔记(一)--MNIST入门 文章目录 Tensorflow2.0学习笔记(一)--MNIST入门 前言 一.MNIST是什么? 二.实现步骤及代码 1.引入库 2.下载 ...

  8. Tensorflow2.0学习笔记(二)

    Tensorflow2.0学习笔记(二)--Keras练习 文章目录 Tensorflow2.0学习笔记(二)--Keras练习 前言 二.使用步骤 1.实现步骤及代码 2.下载 Fashion MN ...

  9. CCC3.0学习笔记_数字密钥数据结构

    CCC3.0学习笔记_数字密钥数据结构 系列文章目录 文章目录 系列文章目录 前言 4.1 Applet Instance Layout 4.2 Digital Key Structure 4.2.1 ...

  10. Tensorflow2.0学习笔记(一)北大曹健老师教学视频1-4讲

    Tensorflow2.0学习笔记(一)北大曹健老师教学视频1-4讲 返回目录 这个笔记现在是主要根据北京大学曹健老师的视频写的,这个视频超级棒,非常推荐. 第一讲 常用函数的使用(包含了很多琐碎的函 ...

最新文章

  1. RDKit | 基于RDKit的PandasTools加速数据分析
  2. MPB:扬州大学王梦芝组-反刍动物瘤胃原虫18S rRNA测序分析技术
  3. SQLyog普通版与SQLyog企业版对比分析
  4. java职业发展路线图_Java程序员如何选择未来的职业路线
  5. nb信号和4g信号_手机信号很强但是4G网络却很卡?学会这三招,立马恢复网速
  6. R可视化lend_club 全球最大的P2P平台数据75W条
  7. 初学者Git和GitHub简介(教程)
  8. 拼多多关联公司申请“碰多多”、“碰碰多”商标
  9. 华为Mate X国行售价曝光,5G网速实测,强悍!
  10. vue 中provide的用法_浅谈vue中provide和inject 用法
  11. linux centos6.5下安装svn方法
  12. getElementById和querySelector方法的区别
  13. SpringBoot2线程池的创建以及执行异步任务
  14. python编写简单运动会管理系统
  15. linux的打包压缩文件,linux打包文件,压缩文件
  16. Mysql如何清空数据库的单表数据 , 所有表数据
  17. 动画制作·边学习边做动画·从零开始的动画世界
  18. 解决 “Windows 功能” 没有Hyper-V
  19. 跨时钟域问题(二)(单bit信号跨时钟域 1. 电平同步器 2. 边沿同步器 3. 脉冲检测器)
  20. Ubuntu软件安装与卸载

热门文章

  1. 第九周-每周例行报告
  2. Windows Mobile 编程 (Win32) - 开篇
  3. React 与 React-Native 使用同一个 meteor 后台
  4. SpringBoot集成Redis分布式锁以及Redis缓存
  5. java中NULL与 的区别
  6. 201521123081《Java程序设计》 第4周学习总结
  7. 在ASP.NET中有关性能与扩展性的秘密知识了解(讨论)
  8. 在.NET/Mono上运行Java:Jeroens Frijters谈IKVM.NET
  9. 【Visual C++】Windows GDI贴图闪烁解决方法
  10. vim文件时自动添加作者、时间、版权等信息