您的位置:首页 > 编程语言 > Java开发

org.springframework.beans.factory.BeanCreationException: Error creating bean with name

2014-12-05 11:46 519 查看
如下报错:

ERROR 12-05 11:34:34(ContextLoader.java:307): Context initialization failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userAccountService' defined in class path resource [applicationContext-service.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException:
Invalid property 'writableSQLSession' of bean class [com.sme.core.service.impl.UserAccountServiceImpl]: Bean property 'writableSQLSession' 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$1.getObject(AbstractBeanFactory.java:295)

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

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

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

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

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

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

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

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

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

    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.start(ContainerBase.java:1057)

    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.NotWritablePropertyException: Invalid property 'writableSQLSession' of bean class [com.sme.core.service.impl.UserAccountServiceImpl]: Bean property 'writableSQLSession' 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)

    ... 28 more

看上面的错,是writableSQLSession没有注入到daoImpl中,或者daoImpl中没有writableSQLSession这个属性。原因是我新添加的一个接口,没有继承baseSerivce,这个baseService里面就是对writableSQLSession进行注入的。修改后没有报错了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring+mybatis
相关文章推荐