preface:
First, post the error report log
Resolved [org.springframework.http.converter.HttpMessageNotWritableException: No converter found for return value of type: class com.test.dto.ResultBean]
If the log is similar, you can continue to look down.
1. Causes and Solutions
Restore the accident scene first (only show the core problem code)
Interface layer code:
@RestController
@RequestMapping("/client")
public class ControllerTest {
@GetMapping("/test")
public ResultBean name() {
return ResultBean.success();
}
}
ResultBean Code:
public class ResultBean {
private String code;
private String result;
ResultBean(String code, String result) {
this.code = code;
this.result = result;
}
public static ResultBean success() {
return new ResultBean("200", "success");
}
}
The error log points to this ResultBean. The big probability is that there is a problem with this bean. After careful analysis of the log, it probably means that it is impossible to get the value, so it is impossible to write. Get the value?Get method?It seems that ResultBean is missing the get method (Lombok annotation is forgotten). With the get method, the problem is solved
Tips: be sure to add get and set methods and try to write by hand; Lombok annotations are rarely used. There are holes in them. Occasionally, the default method for generating special fields cannot be recognized by other components.
Read More:
- Handling nullreference exception problems encountered in NHibernate
- How to handle exception in springboot
- The @ Autowired annotation in springboot is invalid in ordinary classes. How to solve and use the null pointer exception java.lang.nullpointerexception
- MySQL error 1451 23000 foreign key exception handling
- [Jackson exception] com.fasterxml.jackson . databind.JsonMappingException Exception handling method
- SQL exception handling – MySQL error 1005 (HY000): can’t create table ‘TMP’ (errno: 13)
- Springboot project startup exception – required a single bean, but 2 were found
- C / C + + error handling (document): unhandled exception: 0xc0000005: access violation while reading location 0x00000000
- Springboot startup exception: error creating bean with name ‘permissioncontroller’
- Springboot startup error – classnotfound Exception:EnhancerBySpringCGLIB
- Realize the simplest recursive call, simulate exception in thread “main” java.lang.stackoverflowerror exception
- Mex compiler error handling in MATLAB and GCC installation in Ubuntu
- GitHub upload failed: git push error: failed to push some refs to exception handling
- The solution of a Java exception has occurred. And error exception in thread when eclipse runs
- Handling VirtualBox error in super3hardenedwinrespawn
- Error handling method of “no module named ‘stringio’” in Python 3
- Condition judgment and error handling in ansible playbook (fail module failed_when changed_when keyword)
- Error handling of apt instruction e: unmet dependencies. Try ‘apt — fix broken install’ with no packages in Ubuntu 20.04
- Handling of expression not in group by key [value] reported by hive on October 12, 2020
- Cause check of unreachable statement exception in Java