通常,这意味着有一个委派给您的bean的AOP代理。例如,如果您使用注释了一种方法@Transaction。
解决方法Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: protected com.cms.service.FolderService com.cms.action.BaseAction.folderService; nested exception is java.lang.IllegalArgumentException: Can not set com.cms.service.FolderService field com.cms.action.BaseAction.folderService to com.sun.proxy.$Proxy22 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:518) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:287) ... 30 moreCaused by: java.lang.IllegalArgumentException: Can not set com.cms.service.FolderService field com.cms.action.BaseAction.folderService to com.sun.proxy.$Proxy22 at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) at java.lang.reflect.Field.set(Field.java:657) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514) ... 32 more
这是我的基本动作
public class BaseAction { @Autowired protected FolderService folderService; @Autowired protected ArticleService fileService; @Autowired protected TemplateService themeService; @Autowired protected HeadlineService headlineService; protected final Logger logger = Logger.getLogger(this.getClass());}
那就是我的FolderService
@Servicepublic class FolderService { protected final Logger logger = Logger.getLogger(this.getClass()); @Autowired private FolderDao folderDao; @Autowired private AdminFolderDao adminFolderDao; ...................next is the java method}