Spring-20190909
2019-02-21 16:58:44 16 举报
AI智能生成
spring 笔记
作者其他创作
大纲/内容
IoC 容器
Spring BeanFactory容器(简单)
XmlBeanFactory
Spring ApplicationContext容器(高级)
FileSystemXmlApplicationContext
ClassPathXmlApplicationContext
WebXmlApplicationContext
AnnotationConfigApplicationContext
AnnotationConfigEmbeddedWebApplicationContext
类图
Bean
Refenrences
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/Bean.html
https://www.baeldung.com/spring-annotations-resource-inject-autowire
Spring Bean Definition
Bean name
Profile, Scope, Lazy, DependsOn, Primary, Order annotations
@Bean Methods in @Configuration Classes
Annotations
@Configuration + @Bean
@Compnent
@Controller
@Service
inter-bean references
@Bean Lite Mode
@Bean methods may also be declared within classes that are not annotated with @Configuration.
Bean methods in lite mode will be treated as plain factory methods by the container (similar to factory-method declarations in XML)
In contrast to the semantics for bean methods in @Configuration classes, 'inter-bean references' are not supported in lite mode.
BeanFactoryPostProcessor-returning @Bean methods
Dependency Injection
Annotations
@Required
@Required 注解应用于 bean 属性的 setter 方法。
@Autowire
可以应用到 bean 属性的 setter 方法,非 setter 方法,构造函数和属性。
execution paths precedence
Match by Type
Match by Qualifier
Match by Name
JSR-250 Annotations
@Resource
execution paths precedence
Match by Name
Match by Type
Match by Qualifier
@PostConstruct
@PreDestroy
JSR-330 Annotations
@Inject
execution paths precedence
Match by Type
Match by Qualifier
Match by Name
@Named
@Provider
@Qualifier
@Scope
@Singleton
injection type
constructor injection
field injection
setter injection
static factory-method injection
instance factory-method injection
Dependency Lookup
BeanFactory.getBean()
ApplicationContext.getBean()
WebApplicationContextUtils
RequestContextUtils
Configuration
@Configuraion
@Bean
@Import
@Primary
@Profile
@Scope
@Lazy
@Role
@PropertyResurce
@DependsOn
@Conditional
@CompnentScan
transaction
inter-@Transactional method calls
Spring Expression Language (SpEL)
OS Envrionment Variables
Maven Varialbes
System Properties
EvaluationContext
StandardEvaluationContext
0 条评论
下一页