第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

Spring Boot Cache SpEL (#result) 返回 Null

Spring Boot Cache SpEL (#result) 返回 Null

哈士奇WWW 2022-07-20 16:03:45
我有一個(gè) Spring Boot RESTful API 來(lái)接收和發(fā)送 SMS 給客戶端。我的應(yīng)用程序連接到我們的本地短信服務(wù)器,并通過(guò)移動(dòng)運(yùn)營(yíng)商接收短信并將其推送給客戶。我的應(yīng)用程序運(yùn)行良好。但我想通過(guò)實(shí)現(xiàn)緩存來(lái)優(yōu)化我的應(yīng)用程序。我正在使用 Spring Boot 的簡(jiǎn)單緩存。創(chuàng)建新短信時(shí)我面臨一些挑戰(zhàn)。發(fā)送/接收的所有 SMS 都以對(duì)話的形式(每張票)并附有客戶端。所以我面臨著將客戶端保存到緩存中的困難。下面是 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);}當(dāng)我嘗試創(chuàng)建一個(gè)新客戶端時(shí),org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'id' cannot be found on null被拋出。
查看完整描述

1 回答

?
幕布斯7119047

TA貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超8個(gè)贊

而不是使用unless="# result! = null"使用condition="#result != null"



查看完整回答
反對(duì) 回復(fù) 2022-07-20
  • 1 回答
  • 0 關(guān)注
  • 356 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)