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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

Resource不能直接返回嗎?

老師,Resource不能直接返回嗎,為什么需要new一個(gè)新的對(duì)象,copy一份

正在回答

3 回答

同問(wèn)!



0 回復(fù) 有任何疑惑可以回復(fù)我~

老師,我直接返回Resource報(bào)錯(cuò)了,為什么

@RequestMapping("/getResource")

public JsonUtil getResource() {

Resource bean=new Resource();

//BeanUtils.copyProperties(resource, bean);

//System.out.println(resource);

//System.out.println(bean);

return JsonUtil.ok(resource);

}

2018-04-12 13:01:56.862 ?WARN 10980 --- [nio-8090-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.imooc.util.JsonUtil["date"]->com.imooc.model.Resource$$EnhancerBySpringCGLIB$$21953e4a["$$beanFactory"]->org.springframework.beans.factory.support.DefaultListableBeanFactory["beanExpressionResolver"])

2018-04-12 13:01:56.862 ?WARN 10980 --- [nio-8090-exec-3] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.springframework.context.expression.StandardBeanExpressionResolver and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.imooc.util.JsonUtil["date"]->com.imooc.model.Resource$$EnhancerBySpringCGLIB$$21953e4a["$$beanFactory"]->org.springframework.beans.factory.support.DefaultListableBeanFactory["beanExpressionResolver"])


0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

開(kāi)sennsei

應(yīng)該是加載順序有關(guān)系:https://blog.csdn.net/kane0409/article/details/78865964
2018-06-13 回復(fù) 有任何疑惑可以回復(fù)我~
#2

zsir94 回復(fù) 開(kāi)sennsei

其實(shí)不是加載順序原因,調(diào)試可以發(fā)現(xiàn),返回的json串中,該讀取的屬性是有值的,但是可以發(fā)現(xiàn)data中除了屬性文件中的這些字段值,還多了一些屬性,如$$beanFactory,原因應(yīng)該是Resource對(duì)象是Spring構(gòu)造的,Spring給這個(gè)對(duì)象加入元數(shù)據(jù)之類(lèi)的其他屬性,這些屬性Jackson解析不了,所以報(bào)錯(cuò)了,可以看到異常里也提示了 找不到$$beanFactory
2018-07-22 回復(fù) 有任何疑惑可以回復(fù)我~

當(dāng)然可以啦

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

Resource不能直接返回嗎?

我要回答 關(guān)注問(wèn)題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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