byteHunt3r :
내가 받고 고객에게 SMS를 보낼 수있는 봄 부트의 RESTful API를 가지고있다. 내 응용 프로그램은 우리 지역의 SMS 서버에 연결 및 이동 통신 사업자를 통해 고객에게 SMS를 수신하고 푸시합니다. 내 응용 프로그램이 잘 작동합니다. 하지만 캐시를 구현하여 내 응용 프로그램을 최적화하고 싶었다. 나는 봄 부트의 단순 캐시를 사용하고 있습니다. 새로운 SMS를 만들 때 나는 몇 가지 도전에 직면하고 있습니다.
모든 SMS에가 전송 / 수신 (티켓 당) 대화의 형태로 존재와 연결된 클라이언트를 가지고있다. 내가 캐시로 클라이언트를 저장하는 어려운 직면 그래서. 아래 createClient는 () 니펫 :
@Transactional
@Caching(evict = {
@CacheEvict("allClientsPage"),
@CacheEvict("countClients")
}, put = {
@CachePut(value = "clients", key = "#result.id", unless="#result != null"),
@CachePut(value = "clientsByPhone", key = "#result.phoneNumber", unless="#result != null")
})
public Client create(Client client) {
Client c = new Client();
if (client.getName() != null) c.setName(client.getName().trim());
c.setPhoneNumber(client.getPhoneNumber().trim());
/**---***/
c.setCreatedAt(new Date());
return clientRepository.save(c);
}
나는 새로운 클라이언트를 만드는 시도하는
org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'id' cannot be found on null
슬로우됩니다.
모든 지원은 크게 감사해야한다.
펠리페 플로레스 :
사용하는 대신 unless="# result! = null"
사용condition="#result != null"