Bean named 'xx' is expected to be of type 'xx' but was actually of type 'com.sun.proxy.$Proxy29'
当要诸如一个接口的实现类时:

  1. 使用接口来进行类对象转换_
    UserService bean = ac.getBean(“UserServiceImpl”,UserService.class); // UserServiceImpl bean = ac.getBean("UserServiceImpl",UserServiceImpl.class);
  2. 多个不同的实现,根据添加name属性来查找

`
public interface UserService{

}

@Service(“UserServiceImpl”)
public class UserServiceImpl implements UserService{

}

@AutoWired
@Quatifirer(“UserServiceImpl”)
UserService UserServiceImpl;
`

相关文章: