use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class PersonServiceImpl method findOne.
/**
* LayCacheable
* value:缓存key的前缀。
* key:缓存key的后缀。
* sync:设置如果缓存过期是不是只放一个请求去请求数据库,其他请求阻塞,默认是false。
*/
@Override
@Cacheable(value = "people")
public Person findOne() {
Person p = personRepository.findOne(2L);
logger.info("为id、key为:" + p.getId() + "数据做了缓存");
return p;
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class PersonServiceImpl method findOne1.
@Override
// 3
@Cacheable(value = "people#120#120")
public Person findOne1() {
Person p = personRepository.findOne(2L);
System.out.println("为id、key为:" + p.getId() + "数据做了缓存");
return p;
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class PersonServiceImpl method findOne2.
@Override
// 3
@Cacheable(value = "people2")
public Person findOne2(Person person) {
Person p = personRepository.findOne(person.getId());
System.out.println("为id、key为:" + p.getId() + "数据做了缓存");
return p;
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class SpringBootStudentCacheRedisApplicationTests method testParse.
@Test
public void testParse() {
Person p = new Person();
p.setId(11L);
p.setAge(32);
// 表达式解析
ExpressionParser expressionParser = new SpelExpressionParser();
Expression expression = expressionParser.parseExpression("#person.age+\":\"+#person.id");
StandardEvaluationContext context = new StandardEvaluationContext();
context.setRootObject(p);
logger.info("[SpELTest - testParse ] {} ", expression.getValue(context));
Field[] fields = p.getClass().getDeclaredFields();
for (Field field : fields) {
try {
System.out.println("name:" + field.getName());
field.setAccessible(true);
System.out.println("value:" + field.get(p));
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.
the class PersonService method save.
/**
* 保存
* @param person
* @return
*/
@Transactional
public Person save(Person person) {
// 获取配置的数据源
DataSource dataSource = applicationContext.getBean(DataSource.class);
// 查看配置数据源信息
System.out.println(dataSource);
System.out.println(dataSource.getClass().getName());
System.out.println(dataSourceProperties);
Person p = personRepository.save(person);
return p;
}
Aggregations