0 0

使用Hibernate注释不能自动装载30

ERROR: Unable to instantiate Action, com.metinform.app.web.ship.zbgl.ZbryAction,  defined for 'list' in namespace '/secure/ship/zbgl/zbry'Error creating bean with name 'com.metinform.app.web.ship.zbgl.ZbryAction': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.metinform.app.service.ship.bj.BjSchedulePersonService com.metinform.app.web.ship.zbgl.ZbryAction.spService; nested exception is java.lang.IllegalArgumentException: Can not set com.metinform.app.service.ship.bj.BjSchedulePersonService field com.metinform.app.web.ship.zbgl.ZbryAction.spService to $Proxy81
com.opensymphony.xwork2.XWorkException: Unable to instantiate Action, com.metinform.app.web.ship.zbgl.ZbryAction,  defined for 'list' in namespace '/secure/ship/zbgl/zbry'Error creating bean with name 'com.metinform.app.web.ship.zbgl.ZbryAction': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.metinform.app.service.ship.bj.BjSchedulePersonService com.metinform.app.web.ship.zbgl.ZbryAction.spService; nested exception is java.lang.IllegalArgumentException: Can not set com.metinform.app.service.ship.bj.BjSchedulePersonService field com.metinform.app.web.ship.zbgl.ZbryAction.spService to $Proxy81
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:307) [xwork-core-2.1.6.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:388) [xwork-core-2.1.6.jar:na]
at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:187) [xwork-core-2.1.6.jar:na]
at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) [struts2-core-2.1.8.1.jar:na]
at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) [struts2-core-2.1.8.1.jar:na]
at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:47) [xwork-core-2.1.6.jar:na]
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:478) [struts2-core-2.1.8.1.jar:na]
at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) [struts2-core-2.1.8.1.jar:na]
at org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter.doFilter(StrutsExecuteFilter.java:88) [struts2-core-2.1.8.1.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129) [sitemesh-2.4.1.jar:na]
at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77) [sitemesh-2.4.1.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareFilter.doFilter(StrutsPrepareFilter.java:82) [struts2-core-2.1.8.1.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
at com.metinform.app.slf4j.MDCFilter.doFilter(MDCFilter.java:68) [MDCFilter.class:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:67) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:278) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at com.metinform.modules.security.springsecurity.SpringSecurityLogFilter.doFilterHttp(SpringSecurityLogFilter.java:47) [SpringSecurityLogFilter.class:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at com.metinform.app.security.springsecurity.SpringSecurityLogOutLogFilter.doFilterHttp(SpringSecurityLogOutLogFilter.java:67) [SpringSecurityLogOutLogFilter.class:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390) [spring-security-core-2.0.5.jar:na]
at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175) [spring-security-core-2.0.5.jar:na]
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
at org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:110) [cas-client-core-3.1.10.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:96) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) [catalina.jar:na]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) [catalina.jar:na]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) [catalina.jar:na]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) [catalina.jar:na]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) [catalina.jar:na]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [catalina.jar:na]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [catalina.jar:na]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) [catalina.jar:na]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852) [tomcat-coyote.jar:na]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) [tomcat-coyote.jar:na]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) [tomcat-coyote.jar:na]
at java.lang.Thread.run(Thread.java:619) [na:1.6.0_18]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.metinform.app.web.ship.zbgl.ZbryAction': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.metinform.app.service.ship.bj.BjSchedulePersonService com.metinform.app.web.ship.zbgl.ZbryAction.spService; nested exception is java.lang.IllegalArgumentException: Can not set com.metinform.app.service.ship.bj.BjSchedulePersonService field com.metinform.app.web.ship.zbgl.ZbryAction.spService to $Proxy81
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at com.opensymphony.xwork2.spring.SpringObjectFactory.autoWireBean(SpringObjectFactory.java:182) [xwork-core-2.1.6.jar:na]
at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:162) [xwork-core-2.1.6.jar:na]
at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:133) [xwork-core-2.1.6.jar:na]
at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:139) [xwork-core-2.1.6.jar:na]
at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:109) [xwork-core-2.1.6.jar:na]
at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:288) [xwork-core-2.1.6.jar:na]
... 70 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.metinform.app.service.ship.bj.BjSchedulePersonService com.metinform.app.web.ship.zbgl.ZbryAction.spService; nested exception is java.lang.IllegalArgumentException: Can not set com.metinform.app.service.ship.bj.BjSchedulePersonService field com.metinform.app.web.ship.zbgl.ZbryAction.spService to $Proxy81
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
... 78 common frames omitted
Caused by: java.lang.IllegalArgumentException: Can not set com.metinform.app.service.ship.bj.BjSchedulePersonService field com.metinform.app.web.ship.zbgl.ZbryAction.spService to $Proxy81
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146) [na:1.6.0_18]
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150) [na:1.6.0_18]
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63) [na:1.6.0_18]
at java.lang.reflect.Field.set(Field.java:657) [na:1.6.0_18]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:431) [spring-2.5.6.SEC01.jar:2.5.6.SEC01]
... 80 common frames omitted

问题补充:action类
public class ZbryAction extends BaseCRUDAction<BjSchedulePerson> {
@Autowired
private BjSchedulePersonService spService;

业务处理类
@Service
@Transactional
public class BjSchedulePersonService extends BaseDAO<BjSchedulePerson>{
@Autowired
private BjSchedulePersonDAO bjSchedulePersonDAO;

问题补充:DAO
@Repository
@SuppressWarnings("unchecked")
public class BjSchedulePersonDAO extends BaseDAOLocal<BjSchedulePerson> {
2013年5月31日 22:18

2个答案 按时间排序 按投票排序

0 0

Autowired是基于接口注入的。如果是直接注入实现类的话用Resource,通过name属性去查找要装配的对象。

类似的问题及分析请参考:http://bbs.csdn.net/topics/370080304
Autowired与Resource的区别:http://www.chinasb.org/archives/2011/06/2443.shtml

2013年6月02日 23:37
0 0

Could not autowire field: private com.metinform.app.service.ship.bj.BjSchedulePersonService

无法自动加载BjSchedulePersonService。
我猜是不是和你取的名字有关系,把spService改成bjSchedulePersonService试试。

2013年6月02日 10:06

相关推荐

    hibernate注释详解

    hibernate注释详解 内含hibernate各种注释说明

    Hibernate注释深入解析

    本篇文章将深入探讨Hibernate注释的使用。 1. **属性和方法注解** Hibernate允许对类的属性或方法进行注解,以声明它们与数据库表的对应关系。属性注解通常使用`@Column`,它指定了字段在数据库表中的列名、是否...

    hibernate注释源程序

    本篇文章将深入探讨Hibernate中的注释(Annotation)使用以及级联操作,并通过一个简单的源程序实例进行解析。 ### Hibernate 注释 在Hibernate 3.x版本之后,注释成为了一种主流的元数据定义方式,替代了传统的...

    Hibernate-tools解决hbm.xml中文注释乱码和生成实体类注释

    - 为每个数据库表定义清晰的注释,以便在生成实体类时能自动转化为有意义的Java注释。 - 定期更新`Hibernate-tools`,以获取最新的功能和修复的bug。 - 对于复杂的业务场景,可能需要编写自定义的代码生成逻辑,...

    Hibernate 注释语法.chm

    Hibernate 注释语法的简单讲解,个人的学习总结笔记

    Hibernate使用注释

    使用hibernate注释的核心优点是我们不需要创建映射(*.hbm.xml)文件直接创建对象关联。 在这里,hibernate注释用于提供元数据。步骤如下: 1.为MySQL添加连接驱动程序的jar文件(如果数据库是MySQL)和注释2.创建持久化...

    Hibernate注释

    在Java的ORM框架Hibernate中,注解是一种强大的工具,它允许开发者无需XML配置就能将Java对象映射到数据库中的表。下面将详细解释在给定的文件中涉及到的Hibernate注解及其用途。 1. `@Entity`:此注解是Hibernate...

    Eclipse上使用Hibernate

    Eclipse 上使用 Hibernate Eclipse 上使用 Hibernate 是 Java 开发者常用的持久层解决方案。本文将指导您在 Eclipse 环境中使用 Hibernate,包括下载和安装 Hibernate、配置 Hibernate、生成实体类和 DAO 类、添加...

    hibernate自动生成数据库文件

    开发者只需定义好实体类,并使用注解如`@Entity`、`@Table`等来标识表和字段,然后使用Hibernate Tools即可生成对应的DDL(Data Definition Language)脚本,执行这个脚本就能在数据库中创建相应的表结构。...

    Hibernate自动生成表demo

    总的来说,通过使用Hibernate的注解和自动建表功能,我们可以轻松地在Java应用中建立数据库模型,并在运行时自动创建数据库表。这极大地提高了开发效率,降低了出错的可能性,并使得数据库与Java代码之间的关系更加...

    Hibernate 映射文件自动生成

    【压缩包子文件的文件名称列表】:“hibernate映射文件自动生成.doc”很可能是这篇博文的文档形式,其中详细介绍了具体的操作步骤、使用工具或者自定义脚本,以帮助开发者理解并应用自动化的映射文件生成过程。...

    Hibernate通过配置文件自动生成表

    在Java世界中,Hibernate是一个非常流行的对象关系映射(ORM)框架,它简化了数据库操作,使得开发者可以使用面向对象的方式来处理数据。本篇将详细讲解如何通过Hibernate配置文件自动生成数据库表,以及相关的知识...

    hibernate代码自动生成

    使用Hibernate代码自动生成工具有很多优点,例如: - 减少手动编码工作,降低出错率。 - 提高开发速度,使开发者更专注于业务逻辑。 - 便于维护,当数据库表结构发生变化时,只需更新相应的表,工具会自动生成修改...

    myEclipse使用hibernate图解

    ### myEclipse 使用 Hibernate 图解知识点详解 #### 一、集成 Hibernate 类库到 MyEclipse 项目 在 MyEclipse 中使用 Hibernate 开发时,首先需要将 Hibernate 的类库加入到项目中。具体步骤如下: 1. **添加 ...

    使用Hibernate tools,生成带中文注释的类和hbm文件

    下载并安装hibernate tools插件,下载地址:...安装完Hibernate tools插件后,在eclipse安装目录下搜索并替换hibernate-tools-5.2.0.Beta1.jar文件,即可生成带中文注释的类和hbm文件

    hibernate注解所需包

    使用hibernate注解,必须要使用库hibernate-commons-annotations,hibernate-core,hibernate-jpa,ejb3-persistence,javassist等

    hibernate使用参考文档

    Hibernate 使用参考文档 Hibernate 是一个流行的 Java持久层框架,它提供了一种对象关系映射(Object-Relational Mapping,ORM)机制,用于将 Java 对象与关系数据库之间建立映射关系。本文档旨在指导读者快速从 ...

    hibernate@注解方式配置实体类,调用javadoc接口生成数据库表及字段的注释说明

    hibernate@注解方式配置实体类时,利用javadoc接口生成数据库表及字段的注释说明,支持oracle、sqlserver、db2、mysql数据库。因用到java\lib\tools.jar,需要将该jar放入工程lib下(或者tomcat\lib下、或加入...

    使用hibernate做的一个登录的小实例,代码大部分都是自动生成

    通过这个项目,我们可以学习到Hibernate的基本使用方法,包括实体类的创建、持久化配置、数据库交互以及自动生成的映射文件等内容。这个实例特别适合对ORM框架感兴趣,希望学习Hibernate的开发者。 【知识点详解】...

    使用代理实现Hibernate Dao层自动事务

    本文将深入探讨如何使用代理来实现Hibernate Dao层的自动事务管理,以提高代码的可维护性和事务处理的效率。 首先,理解Dao(Data Access Object)层的作用至关重要。Dao层是应用与数据库之间的一层抽象,它封装了...

Global site tag (gtag.js) - Google Analytics