没有合适的资源?快使用搜索试试~ 我知道了~
spring-framework-reference-4.3.1.RELEASE
需积分: 1 12 下载量 186 浏览量
2016-07-21
14:14:05
上传
评论
收藏 5.46MB PDF 举报
温馨提示
试读
907页
spring-framework-reference-4.3.1.RELEASE
资源推荐
资源详情
资源评论
Spring Framework Reference Documentation
4.3.1.RELEASE
Rod Johnson , Juergen Hoeller , Keith Donald , Colin Sampaleanu , Rob Harrop , Thomas Risberg , Alef
Arendsen , Darren Davison , Dmitriy Kopylenko , Mark Pollack , Thierry Templier , Erwin Vervaet , Portia
Tung , Ben Hale , Adrian Colyer , John Lewis , Costin Leau , Mark Fisher , Sam Brannen , Ramnivas
Laddad , Arjen Poutsma , Chris Beams , Tareq Abedrabbo , Andy Clement , Dave Syer , Oliver Gierke ,
Rossen Stoyanchev , Phillip Webb , Rob Winch , Brian Clozel , Stephane Nicoll , Sebastien Deleuze
Copyright © 2004-2015
Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee
for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.
Spring Framework Reference Documentation
4.3.1.RELEASE Spring Framework iii
Table of Contents
I. Overview of Spring Framework ................................................................................................ 1
1. Getting Started with Spring ............................................................................................. 2
2. Introduction to the Spring Framework .............................................................................. 3
2.1. Dependency Injection and Inversion of Control ...................................................... 3
2.2. Modules .............................................................................................................. 3
Core Container .................................................................................................. 4
AOP and Instrumentation ................................................................................... 5
Messaging ......................................................................................................... 5
Data Access/Integration ...................................................................................... 5
Web .................................................................................................................. 5
Test ................................................................................................................... 6
2.3. Usage scenarios ................................................................................................. 6
Dependency Management and Naming Conventions ............................................ 9
Spring Dependencies and Depending on Spring ......................................... 11
Maven Dependency Management ............................................................. 11
Maven "Bill Of Materials" Dependency ....................................................... 12
Gradle Dependency Management ............................................................. 12
Ivy Dependency Management ................................................................... 13
Distribution Zip Files ................................................................................. 13
Logging ............................................................................................................ 13
Not Using Commons Logging ................................................................... 14
Using SLF4J ............................................................................................ 14
Using Log4J ............................................................................................. 15
II. What’s New in Spring Framework 4.x .................................................................................... 17
3. New Features and Enhancements in Spring Framework 4.0 ............................................ 18
3.1. Improved Getting Started Experience .................................................................. 18
3.2. Removed Deprecated Packages and Methods .................................................... 18
3.3. Java 8 (as well as 6 and 7) ............................................................................... 18
3.4. Java EE 6 and 7 ............................................................................................... 19
3.5. Groovy Bean Definition DSL .............................................................................. 19
3.6. Core Container Improvements ............................................................................ 19
3.7. General Web Improvements ............................................................................... 20
3.8. WebSocket, SockJS, and STOMP Messaging ..................................................... 20
3.9. Testing Improvements ........................................................................................ 21
4. New Features and Enhancements in Spring Framework 4.1 ............................................ 22
4.1. JMS Improvements ............................................................................................ 22
4.2. Caching Improvements ...................................................................................... 22
4.3. Web Improvements ............................................................................................ 23
4.4. WebSocket Messaging Improvements ................................................................. 24
4.5. Testing Improvements ........................................................................................ 24
5. New Features and Enhancements in Spring Framework 4.2 ............................................ 26
5.1. Core Container Improvements ............................................................................ 26
5.2. Data Access Improvements ................................................................................ 27
5.3. JMS Improvements ............................................................................................ 28
5.4. Web Improvements ............................................................................................ 28
5.5. WebSocket Messaging Improvements ................................................................. 29
5.6. Testing Improvements ........................................................................................ 29
Spring Framework Reference Documentation
4.3.1.RELEASE Spring Framework iv
6. New Features and Enhancements in Spring Framework 4.3 ............................................ 32
6.1. Core Container Improvements ............................................................................ 32
6.2. Data Access Improvements ................................................................................ 32
6.3. Caching Improvements ...................................................................................... 32
6.4. JMS Improvements ............................................................................................ 32
6.5. Web Improvements ............................................................................................ 33
6.6. WebSocket Messaging Improvements ................................................................. 33
6.7. Testing Improvements ........................................................................................ 33
6.8. Support for new library and server generations .................................................... 34
III. Core Technologies .............................................................................................................. 35
7. The IoC container ........................................................................................................ 36
7.1. Introduction to the Spring IoC container and beans .............................................. 36
7.2. Container overview ............................................................................................ 36
Configuration metadata ..................................................................................... 37
Instantiating a container .................................................................................... 38
Composing XML-based configuration metadata .......................................... 39
Using the container .......................................................................................... 40
7.3. Bean overview ................................................................................................... 40
Naming beans .................................................................................................. 41
Aliasing a bean outside the bean definition ................................................ 42
Instantiating beans ........................................................................................... 43
Instantiation with a constructor .................................................................. 44
Instantiation with a static factory method .................................................... 44
Instantiation using an instance factory method ........................................... 44
7.4. Dependencies ................................................................................................... 46
Dependency Injection ....................................................................................... 46
Constructor-based dependency injection .................................................... 46
Setter-based dependency injection ............................................................ 48
Dependency resolution process ................................................................. 49
Examples of dependency injection ............................................................. 50
Dependencies and configuration in detail ........................................................... 52
Straight values (primitives, Strings, and so on) ........................................... 52
References to other beans (collaborators) .................................................. 54
Inner beans .............................................................................................. 55
Collections ............................................................................................... 55
Null and empty string values ..................................................................... 57
XML shortcut with the p-namespace .......................................................... 58
XML shortcut with the c-namespace .......................................................... 59
Compound property names ....................................................................... 60
Using depends-on ............................................................................................ 60
Lazy-initialized beans ....................................................................................... 60
Autowiring collaborators .................................................................................... 61
Limitations and disadvantages of autowiring ............................................... 62
Excluding a bean from autowiring .............................................................. 63
Method injection ............................................................................................... 63
Lookup method injection ........................................................................... 64
Arbitrary method replacement ................................................................... 66
7.5. Bean scopes ..................................................................................................... 67
The singleton scope ......................................................................................... 68
The prototype scope ......................................................................................... 68
Spring Framework Reference Documentation
4.3.1.RELEASE Spring Framework v
Singleton beans with prototype-bean dependencies ............................................ 69
Request, session, global session, application, and WebSocket scopes ................. 70
Initial web configuration ............................................................................ 70
Request scope ......................................................................................... 71
Session scope .......................................................................................... 71
Global session scope ............................................................................... 71
Application scope ..................................................................................... 72
Scoped beans as dependencies ................................................................ 72
Custom scopes ................................................................................................ 74
Creating a custom scope .......................................................................... 74
Using a custom scope .............................................................................. 75
7.6. Customizing the nature of a bean ....................................................................... 76
Lifecycle callbacks ............................................................................................ 76
Initialization callbacks ............................................................................... 77
Destruction callbacks ................................................................................ 77
Default initialization and destroy methods .................................................. 78
Combining lifecycle mechanisms ............................................................... 79
Startup and shutdown callbacks ................................................................ 80
Shutting down the Spring IoC container gracefully in non-web applications
................................................................................................................. 82
ApplicationContextAware and BeanNameAware ................................................. 82
Other Aware interfaces ..................................................................................... 83
7.7. Bean definition inheritance ................................................................................. 84
7.8. Container Extension Points ................................................................................ 86
Customizing beans using a BeanPostProcessor ................................................. 86
Example: Hello World, BeanPostProcessor-style ........................................ 87
Example: The RequiredAnnotationBeanPostProcessor ............................... 89
Customizing configuration metadata with a BeanFactoryPostProcessor ................ 89
Example: the Class name substitution PropertyPlaceholderConfigurer .......... 90
Example: the PropertyOverrideConfigurer .................................................. 91
Customizing instantiation logic with a FactoryBean ............................................. 92
7.9. Annotation-based container configuration ............................................................ 92
@Required ....................................................................................................... 94
@Autowired ..................................................................................................... 94
Fine-tuning annotation-based autowiring with @Primary ..................................... 97
Fine-tuning annotation-based autowiring with qualifiers ....................................... 98
Using generics as autowiring qualifiers ............................................................ 103
CustomAutowireConfigurer .............................................................................. 104
@Resource .................................................................................................... 104
@PostConstruct and @PreDestroy .................................................................. 106
7.10. Classpath scanning and managed components ................................................ 106
@Component and further stereotype annotations ............................................. 106
Meta-annotations ............................................................................................ 107
Automatically detecting classes and registering bean definitions ........................ 108
Using filters to customize scanning .................................................................. 109
Defining bean metadata within components ..................................................... 110
Naming autodetected components ................................................................... 112
Providing a scope for autodetected components ............................................... 113
Providing qualifier metadata with annotations ................................................... 114
7.11. Using JSR 330 Standard Annotations ............................................................. 115
剩余906页未读,继续阅读
资源评论
qinxike
- 粉丝: 37
- 资源: 62
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功