Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.yinlian.wssc.web.service.impl.SupplierSkuServiceImpl com.yinlian.wssc.web.service.impl.OrderServiceImpl.sskuService; nested exception is java.lang.IllegalArgumentException: Can not set com.yinlian.wssc.web.service.impl.SupplierSkuServiceImpl field com.yinlian.wssc.web.service.impl.OrderServiceImpl.sskuService to com.sun.proxy.$Proxy157
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 22 more
Caused by: java.lang.IllegalArgumentException: Can not set com.yinlian.wssc.web.service.impl.SupplierSkuServiceImpl field com.yinlian.wssc.web.service.impl.OrderServiceImpl.sskuService to com.sun.proxy.$Proxy157
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 22 more
Caused by: java.lang.IllegalArgumentException: Can not set com.yinlian.wssc.web.service.impl.SupplierSkuServiceImpl field com.yinlian.wssc.web.service.impl.OrderServiceImpl.sskuService to com.sun.proxy.$Proxy157
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)
... 24 more
今天遇到autowire异常 查了网上说的几种情况
autowire异常主要情况发生的
像上面的情况是自动写入的时候把接口写成实现类了
@Autowired
private SupplierSkuServiceImpl SupplierSkuService;
应该是
@Autowired
private SupplierSkuService SupplierSkuService ;
以下是从其他地方看到的
还有别的情况可能是:
1。你的BrandServiceImpl必须以@Service或@Component注解才行。
2。自动写入的时候把接口写成实现类了
@Autowired
private BrandServiceImpl brandServiceImpl;
应该是
@Autowired
private BrandService brandService ;
3.在BrandDao 类上加上@Repository注解