-
spring 为struts2 所以的action 实现aop编程问题5
在项目中我用spring 的aop为struts2中的每个action都进行aop编程(动态代理)
看我的aop文件配置:
<!-- 前台spring拦截器 -->
<bean id="frontHeaderInterceptor" class="com.kuquo.code.springInterceptor.FrontHeaderInterceptor"></bean>
<aop:config proxy-target-class="false">
<aop:aspect ref="frontHeaderInterceptor" >
<aop:pointcut expression="execution(public java.lang.String com.kuquo.app.front.action.*.*())" id="frontActionPointcut" />
<aop:after method="afterFrontAction" pointcut-ref="frontActionPointcut"/>
<aop:before method="beforeFrontAction" pointcut-ref="frontActionPointcut"/>
</aop:aspect>
</aop:config>
我的expression="execution(public java.lang.String com.kuquo.app.front.action.*.*()) 是为这个包下面的所以action类进行动态代理的。
但是tomcat启动时报错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'SysPowerAction' defined in file [D:\apache-tomcat-6.0.33\webapps\mall\WEB-INF\classes\conf\spring\applicationContext-admin-action.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysPowerService' defined in file [D:\apache-tomcat-6.0.33\webapps\mall\WEB-INF\classes\conf\spring\applicationContext-admin-service.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysRolePowerService' defined in file [D:\apache-tomcat-6.0.33\webapps\mall\WEB-INF\classes\conf\spring\applicationContext-admin-service.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysPowerService' defined in file [D:\apache-tomcat-6.0.33\webapps\mall\WEB-INF\classes\conf\spring\applicationContext-admin-service.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysRolePowerService' defined in file [D:\apache-tomcat-6.0.33\webapps\mall\WEB-INF\classes\conf\spring\applicationContext-admin-service.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByName(AbstractAutowireCapableBeanFactory.java:1027)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:975)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 38 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sysRolePowerService' defined in file [D:\apache-tomcat-6.0.33\webapps\mall\WEB-INF\classes\conf\spring\applicationContext-admin-service.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:478)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByName(AbstractAutowireCapableBeanFactory.java:1027)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:975)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 49 more
Caused by: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:391)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1287)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1248)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1008)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:470)
... 60 more
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:219)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:386)
... 64 more
spring 竟然报的是为publicDAO 这个类的错?为什么?
Cannot convert value of type [$Proxy3] to required type [com.kuquo.code.ibatis.impl.PublicDAO] for property 'publicDAO': no matching editors or conversion strategy found2013年12月18日 15:41
目前还没有答案
相关推荐
在这个"spring和struts的整合-aop的使用"主题中,我们将深入探讨如何将Spring与Struts2集成,并利用Spring的AOP实现日志记录。 首先,整合Spring和Struts2的关键在于配置。通常,我们需要在Struts2的配置文件...
4. **连接Struts2和Spring**:在Struts2的配置文件(如`struts.xml`)中,我们需要配置Action类以使用Spring的依赖注入,这样Spring才能识别并应用AOP代理。 在实际的项目中,我们还需要考虑如何处理自定义参数。...
Spring 提供了强大的依赖注入(DI)和面向切面编程(AOP),而 Struts2 则是用于处理 HTTP 请求和展现视图的优秀框架。将这两个框架整合在一起可以构建出高效、模块化的 Web 应用。 首先,我们来理解 Spring 框架的...
同时,Spring与Struts2可以通过Spring-Struts2插件无缝集成,使得Action可以直接由Spring管理,增强了系统的可测试性。 **MyBatis** 是一个轻量级的持久层框架,它将SQL语句与Java代码分离,提供了更灵活的SQL操作...
本项目"Spring+Struts2+JQuery实现简单的登录功能"正是以此为基础,通过集成这三个组件,实现了用户登录这一基础功能。 Spring框架作为Java企业级应用的核心,它提供了依赖注入(DI)和面向切面编程(AOP)等核心...
这通常通过使用Spring的Struts2插件来实现,该插件允许Struts2从Spring容器中获取和管理Action实例。 步骤一:配置Spring 在Spring的配置文件中,我们需要声明Action类为Spring管理的bean,例如: ```xml <!-- ...
Spring是一个全面的后端框架,涵盖了依赖注入、事务管理、AOP(面向切面编程)等多个方面,而Struts 2则主要负责MVC(模型-视图-控制器)架构中的控制层。这两者的整合使得开发者可以构建出更高效、可维护的企业级...
Spring以其强大的依赖注入(DI)和面向切面编程(AOP)能力,而Struts2则以其优秀的MVC设计模式著称,两者结合可以构建出高效、可维护的Web应用。本文将基于"spring+struts2整合源码"的标题和描述,详细讲解Spring和...
Spring 提供了全面的依赖注入(DI)和面向切面编程(AOP)功能,而 Struts2 则是用于构建 MVC(Model-View-Controller)架构的优秀框架。将两者结合使用,可以构建出高效、可维护性高的 web 应用程序。 首先,让...
Spring以其强大的依赖注入(DI)和面向切面编程(AOP)能力,而Struts2则以其优秀的MVC设计模式著称,两者整合可以构建出高效、可维护的Web应用。下面将详细介绍Spring与Struts2整合的相关知识点。 **一、整合背景*...
总的来说,Spring、Struts2和iBatis的整合为Java Web开发提供了一个强大、灵活的解决方案,让开发者能够更专注于业务逻辑,而不是框架的底层实现。通过合理的配置和使用这个jar包,开发者可以快速构建出稳定、高性能...
4. **整合步骤**:配置Struts2的Spring插件,使Struts2能够从Spring容器中获取Action实例。在Action类中注入Service,Service再注入DAO,形成完整的依赖链。 5. **测试**:编写JUnit测试用例,验证Spring、Struts2...
Struts2的动作类通常会注入Spring管理的服务层对象,而这些对象的事务管理可以通过Spring的AOP来实现。Hibernate的SessionFactory也会在Spring中被声明和初始化,以便在需要时获取Session对象进行数据库操作。 5. *...
在IT行业中,SSH(Spring、Struts2、Hibernate)是一个经典的Java Web开发框架组合,而Redis则是一个高性能的键值存储系统,常用于缓存和数据持久化。将SSH与Redis整合,可以提升应用程序的性能和响应速度。下面将...
通过在struts-config.xml和action-servlet.xml之间建立的桥梁,即action-mapping,可以实现Struts Action与Spring Bean之间的映射。 #### 方案二:继承Spring的ActionSupport类 另一种整合方式是通过继承Spring的...
Struts2与Spring的整合使得我们可以直接在Spring容器中声明和管理Action,实现请求的转发和结果的渲染。 接着,MyBatis是数据库操作的利器,它允许开发者直接编写SQL语句,将SQL与Java代码紧密结合,避免了...
在实际项目中,通常使用Spring来管理Struts2的Action实例,通过Spring的DI实现Action类的依赖注入。同时,Spring负责管理Hibernate SessionFactory,提供透明的事务管理。在Struts2的Action执行完毕后,可以通过...
**Spring框架**是Java应用开发的核心框架,它提供了全面的编程和配置模型,支持依赖注入(DI)、面向切面编程(AOP)以及多种应用集成。在整合中,Spring主要负责管理业务对象和事务处理,提供服务层的接口和实现。 ...
总的来说,Spring+Struts2+MyBatis的组合为开发者提供了一个强大的开发工具,使得我们可以快速构建功能完善的Web应用,同时保证了代码的可维护性和扩展性。在实际开发中,还需要根据具体需求进行调整和优化,如安全...
在"Spring+Struts2+Ibatis"的整合中,通常会使用Spring作为整个应用的基础架构,提供DI和AOP功能,管理Struts2的Action和iBatis的SqlSession。Struts2作为前端控制器,处理HTTP请求,调用Spring管理的Service层方法...