问答详情
源自:4-3 配置Action,Service,Dao的类-Struts2整合Spring

service中的save方法怎么转到product里面了,而不是dao里面

http://img.mukewang.com/5825a8b400017f7305970596.jpg



运行报错



ERROR - Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ProductService' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'cn.mooc.dao.ProductDao' to required type 'cn.mooc.daoMain.Product' for property 'ProductDao'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [cn.mooc.dao.ProductDao] to required type [cn.mooc.daoMain.Product] for property 'ProductDao': no matching editors or conversion strategy found

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)

at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)

at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)

at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)

at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)

at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)

at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)

at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1229)

at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1875)

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)

at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

at java.util.concurrent.FutureTask.run(FutureTask.java:138)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

at java.lang.Thread.run(Thread.java:619)

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'cn.mooc.dao.ProductDao' to required type 'cn.mooc.daoMain.Product' for property 'ProductDao'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [cn.mooc.dao.ProductDao] to required type [cn.mooc.daoMain.Product] for property 'ProductDao': no matching editors or conversion strategy found

at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485)

at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516)

at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)

... 25 more

Caused by: java.lang.IllegalStateException: Cannot convert value of type [cn.mooc.dao.ProductDao] to required type [cn.mooc.daoMain.Product] for property 'ProductDao': no matching editors or conversion strategy found

at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241)

at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470)

... 31 more

2016-11-11 18:24:06 org.apache.catalina.core.StandardContext startInternal

严重: Error listenerStart

2016-11-11 18:24:06 org.apache.catalina.core.StandardContext startInternal

严重: Context [/ssh] startup failed due to previous errors

2016-11-11 18:24:06 org.apache.catalina.core.ApplicationContext log

信息: Closing Spring root WebApplicationContext

2016-11-11 18:24:06 org.apache.coyote.AbstractProtocol start

信息: Starting ProtocolHandler ["http-apr-8080"]

2016-11-11 18:24:06 org.apache.coyote.AbstractProtocol start

信息: Starting ProtocolHandler ["ajp-apr-8009"]

2016-11-11 18:24:06 org.apache.catalina.startup.Catalina start

信息: Server startup in 17096 ms


提问者:玄鉴 2016-11-11 19:18

个回答

  • 玄鉴
    2016-11-11 20:00:22

    哦哦 找到原因了,private ProductDao productDao;谢谢大家了。