错误信息
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'lockController': Unsatisfied dependency expressed through field 'mqttService'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'mqttServiceImpl' is expected to be of type 'com.hotel.luck.service.MqttServiceImpl' but was actually of type 'com.sun.proxy.$Proxy31'
找了一些博客说是spring注解注入的问题,下面是我的注入code
问题出在MqttServiceImpl上,网上说jdk的动态代理不支持类注入,只支持接口注入,但我另外四个注入均是实现类不是接口,留个疑问,学精spring之后再回头来看。
解决方法:将MqttServiceImpl改成MqttService接口。