1.Bean的scope:spring 中常用的两个bean scope:singleleton 和 protoype 单例模式和每次都new一个新对象
2.spring el表达式:@value注解的使用一些常用eg:
@propertySource(classpath:xxx 在web-inf 的classes 路径下)
@value("i love you")
private String noraml
@value("#{systemProperties[os.name]}") 注入操作系统属性
@value("#T(java.lang.Math).random()") el表达式用T()执行java函数
@value("#demoService.another")el表达式调用其他类的属性
@value(classpath:直接加载txt等文件)
@value("${bookj.name}") 从propertie中读内容
3.bean 的初始化和摧毁:可以使用init-method 和 destoryMethod 来确定初始化和销毁bean
jsr250 使用@PostConStruct 和 @PreDestroy来完成类似功能。
4.profile :为不同环境下使用不同配置,可以在@bean 上定义@profile("xxxxx")环境。
5.springAware 为bean提供spring容器的服务(暂时未使用)
6.开启多线程@Async 来声明异步 使用EnableAsync 来开启异步。使用@Scheduled 声明计划任务 使用时也需要先开启任务 使用@EnableScheduling 注解
7.springBoot 常用注解@conditonal 根据条件来动态注解
8.组合注解 可以通过声明@interface 去自己构造组合注解 @restController 就是一个组合注解

被折叠的 条评论
为什么被折叠?



