学习Spring的项目 工作了这么多年,一直都没有系统的学习和总结Spring的知识。现在开始复习和总结,同时也是复习一下Spring的知识。 从12年开始算起,做Java开发也有4年的时间了,很久了。。。
xinjian0728 / learnspringproject Goto Github PK
View Code? Open in Web Editor NEW学习Spring的项目
License: The Unlicense
学习Spring的项目
License: The Unlicense
Spring IoC容器如何实例化Bean呢?传统应用程序可以通过new和反射方式进行实例化Bean。而Spring IoC容器则需要根据Bean定义里的配置元数据使用反射机制来创建Bean。在Spring IoC容器中根据Bean定义创建Bean主要有以下几种方式:
一、 使用构造器实例化Bean:这是最简单的方式,Spring IoC容器即能使用默认空构造器也能使用有参数构造器两种方式创建Bean,如以下方式指定要创建的Bean类型:
使用空构造器进行定义,使用此种方式,class属性指定的类必须有空构造器
使用有参数构造器进行定义,使用此中方式,可以使用< constructor-arg >标签指定构造器参数值,其中index表示位置,value表示常量值,也可以指定引用,指定引用使用ref来引用另一个Bean定义,后边会详细介绍:
<constructor-arg index="0" value="Hello Spring!"/>
在配置文件(resources/chapter2/instantiatingBean.xml)配置Bean定义,如下所示:
<constructor-arg index="0" value="Hello Spring!"/>
整个复习Spring的项目情况说明:
使用eclipse作为开发环境,使用maven管理依赖,避免去下载不同的jar,集成到项目还要处理兼容问题,使用git插件作为版本控制工具。所有编写的代码,都要写Junit测试,保证测试覆盖率。
Spring的核心:IOC容器的实现
IOC容器和依赖反转
依赖注入
解耦代码和提高代码的可测试性
IOC是实现依赖注入的载体,它可以在对象生成或初始化时直接将数据注入到对象中,也可以通过将对象引用注入到对象数据域中的方式来注入对方法调用的依赖。
IOC容器的设计和实现:BeanFactory和ApplicationContext,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.