ssh框架:

xiaoxiao2021-02-27  155

ERROR Dispatcher:38 - Exception occurred during processing request: Unable to instantiate Action, cartAction,  defined for 'cart_addCart' in namespace '/'Error creating bean with name 'cartAction' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'productService' of bean class [com.itcast.shop.cart.action.CartAction]: Bean property 'productService' is not writable or has an invalid setter method . Does the parameter type of the setter match the return type of the getter? Unable to instantiate Action, cartAction,  defined for 'cart_addCart' in namespace '/'Error creating bean with name 'cartAction' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'productService' of bean class [com.itcast.shop.cart.action.CartAction]: Bean property 'productService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?     at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:316)     at com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:397)     at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:194)     at org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)     at org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39)     at com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)     at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:553)     at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)     at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)     at java.lang.Thread.run(Thread.java:744) Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cartAction' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'productService' of bean class [com.itcast.shop.cart.action.CartAction]: Bean property 'productService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1427)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1132)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:314)     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)     at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1117)     at com.opensymphony.xwork2.spring.SpringObjectFactory.buildBean(SpringObjectFactory.java:151)     at com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:151)     at com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:121)     at com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:297)     ... 23 more Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'productService' of bean class [com.itcast.shop.cart.action.CartAction]: Bean property 'productService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?     at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1044)     at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:904)     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)     at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1424)

    ... 33 more

producService 忘了提供setter方法

如果出现Caused by: java.lang.ClassNotFoundException: userAction异常,则可能是struts配置文件action的class属性名和spring配置问价的bean的id属性名不一致导致

若果出现错误,一定要认真看错误提示,不要急于网上找解决方法。

转载请注明原文地址: https://www.6miu.com/read-9762.html

最新回复(0)