admin管理员组

文章数量:1530342

在用ssm做项目时,出现了如下错误:

     Error creating bean with name 'supplierAction': 
        Injection of resource dependencies failed; 
        nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: 
        Bean named 'supplierService' must be of type [cn.zua.scm.service.SupplierService],
         but was actually of type [com.sun.proxy.$Proxy31]

找了两个多小时,也在网上查了很多资料,最后发现是自己的Service实现类继承错了接口,   

     应该是:public class SupplierServiceImpl implements SupplierService           

    却粗心的写成了:public class SupplierServiceImpl implements SupplierMapper。

另外,新手一定要注意注解的名字和类型名是否一致,否则spring也会注入失败:

    例如:

          注解名是supplierService

        @Service("supplierService")

        public class SupplierServiceImpl implements SupplierService

        但是注入的时候却用的service

        @Resource

        private SupplierService service;

        应该是:

        @Resource

        private SupplierService supplierService;

    




本文标签: xxxtypeSUNproxy