Spring获取bean异常

0

org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'wordService' is expected to be of type 'com.acgist.service.impl.WordService' but was actually of type 'com.sun.proxy.$Proxy51'
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:389)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:224)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1015)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:339)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:334)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1107)
	
java.lang.ClassCastException: com.sun.proxy.$Proxy50 cannot be cast to com.acgist.service.impl.WeiXinService
	at com.acgist.module.initializer.impl.WeiXinInitializer.init(WeiXinInitializer.java:22)
	at com.acgist.module.initializer.InitializerManager.lambda$0(InitializerManager.java:61)

使用WebApplicationContext.getBean(Class<?> clazz)时出现上面的错误。
其中结构是这样:IWeiXinService是接口,WeiXinService实现了IWeiXinService接口。
代码如下:

IWeiXinService weiXinService1 = SpringUtils.getBean(IWeiXinService.class);
IWeiXinService weiXinService2 = (IWeiXinService) SpringUtils.getBean("weiXinService");
IWeiXinService weiXinService3 = SpringUtils.getBean(WeiXinService.class);
WeiXinService weiXinService4 = (WeiXinService) SpringUtils.getBean("weiXinService");

上面四种获取方法,后面两种分别对应上面的异常。