1. @Transaction 事务

TransactionSynchronizationManager

用以存储并维护SqlSessionHolder,存于ThreadLocal中,待持久层框架Mybatis在获取SqlSession时直接使用此缓存下的SQLSession,mybatis关sqlsession时也在此release,并非真正意义的关闭;

2. @Async 异步

3. @Scadular 定时任务

4. Yml转换

4.1. YamlPropertiesFactoryBean

YamlPropertiesFactoryBean可以设置一个或一组Resource,通过在需要时通过getObject()可以解析得到Properties配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
* 将yml文件转换为Properties
* @param paths classpath路径
* @return
*/
public static Properties parse2Properties(String... paths){
YamlPropertiesFactoryBean bean = new YamlPropertiesFactoryBean();
Resource[] resources = new Resource[paths.length];
for (int i = 0; i < paths.length; i++) {
String path=paths[i];
if (path.startsWith("classpath:")){
path=path.substring("classpath:".length());
}
resources[i]=new ClassPathResource(path);
}
bean.setResources(resources);
return bean.getObject();
}