admin管理员组

文章数量:1530266

but was actually of type ‘com.sun.proxy.$Proxy25’

spring整合mybatis时的错误

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘accountController’: Unsatisfied dependency expressed through field ‘accountService’; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named ‘accountService’ is expected to be of type ‘com.zyg.service.impl.AccountServiceImpl’ but was actually of type’com.sun.proxy.$Proxy25’

其实就是自己迷了在Controller类中定义的accountService定义成AccountServiceImpl 了,改成接口类IAccountService 就好了

错误代码

@Controller
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private AccountServiceImpl accountService;
    @RequestMapping("/findAll")
    public String findAll(Model model){
        System.out.println("表现层查询信息");
        List<Account> list = accountService.findAll();
        model.addAttribute("list",list);
        return "list";

    }
    @RequestMapping("/save")
    public String save(Account account){
        accountService.save(account);
        return "list";
    }

}

修改过的代码

@Controller
@RequestMapping("/account")
public class AccountController {
    @Autowired
    private IAccountService accountService;
    @RequestMapping("/findAll")
    public String findAll(Model model){
        System.out.println("表现层查询信息");
        List<Account> list = accountService.findAll();
        model.addAttribute("list",list);
        return "list";

    }
    @RequestMapping("/save")
    public String save(Account account){
        accountService.save(account);
        return "list";
    }

}

本文标签: 错误SpringJavatypeproxy