Java. Lang. illegalstateexception: cannot convert value of type ...... To ......
No matching editors or conversion strategy found
This problem is really confusing.
No matching editors or conversion strategy found.
After the problem was solved, I still don't know why. Let's talk about my problems and solutions.
First, I have three classes: accountservice, drawaccountservice, and curraccountservice. These three classes all inherit from a crudservice and have similar basic functions. However, they target different Dao classes, and different Dao classes target different entities and tables.
I called them in three related actions, corresponding to accountinteraction, drawaccountinteraction, and curraccountinteraction.
In accountinteraction, I autowared the accountservice. The definition is as follows:
private AccountService accountService;@Autowiredpublic void setAccountService(AccountService accountService) {this.accountService = accountService;}
Then call this accountservice to execute some related functions. Well, these are all correct. The problem is as follows.
Then, in drawaccountinteraction and curraccountinteraction, I also autowared their corresponding drawaccountservice and curraccountservice. The classes are different, but the variable names are the same, in these two actions, my reference statements are as follows:
private DrawAccountService accountService;@Autowiredpublic void setAccountService(DrawAccountService accountService) {this.accountService = accountService;}
private CurrAccountService accountService;@Autowiredpublic void setAccountService(CurrAccountService accountService) {this.accountService = accountService;}
Note: The Defined variable types are different, but the variable names are the same.
When calling the two service-related functions in drawaccountinteraction and curraccountinteraction, an error message is displayed, such as Java. Lang. illegalstateexception: cannot convert value of Type accountservice to drawaccountservcie. I am a bit puzzled, because I have not switched?
Later, the dead horse was a dead horse doctor. Since all the prompted errors mentioned accountservice, I changed this variable to another name. So in drawaccountinteraction and curraccountinteraction, I changed the two referenced variables to the following names:
private DrawAccountService drawAccountService;@Autowiredpublic void setDrawAccountService(DrawAccountService drawAccountService) {this.drawAccountService = drawAccountService;}
private CurrentAccountService currAccountService;@Autowiredpublic void setCurrAccountService(CurrentAccountService currAccountService) {this.currAccountService = currAccountService;}
Yes, the variable name is modified, and then everything is normal. To be honest, I cannot understand it.
For now.