在使用springboot做項目時遇到了 SpringBoot:HttpMessageNotWritableException: No converter found for return value of type 這個問題,由於springboot項目中對json數據轉換的依賴已經在web依賴中配置好了,所以在springboot中對於大多數答案中的json-core、json-annotationa、json-databind的依賴的問題不用關心,這是使用springmvc需要自己添加依賴帶來的問題。我出現這個問題的原因是沒有添加getter和setter,由於使用靜態方法創建返回數據對象的實例,所以沒有添加getter和setter,導致對象轉json對象時無法解析。添加getter和setter方法后解決,是否有其他原因待定。
參考鏈接地址:https://blog.csdn.net/sinat_29047129/article/details/104879904