spring-【新手学习Spring】报错了,根本看不懂。

问题描述

【新手学习Spring】报错了,根本看不懂。

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userAction' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Cannot resolve reference to bean 'userService' while setting bean property 'userService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao' of bean class [com.user.service.impl.UserServiceImpl]: Bean property 'userDao' 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.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:924)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:887)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
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:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userService' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao' of bean class [com.user.service.impl.UserServiceImpl]: Bean property 'userDao' 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:1361)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
... 39 more
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao' of bean class [com.user.service.impl.UserServiceImpl]: Bean property 'userDao' 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:1024)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:900)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
... 47 more

解决方案

UserAction和UserService可能在引用上出现了问题

解决方案二:

Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userDao' of bean class [com.user.service.impl.UserServiceImpl]: Bean property 'userDao' is not writable or has an invalid setter method.
主要是这句错,他说你在spring的配置文件applicationContext.xml里的错误设置了属性值。然后是不可写属性异常;上面提示的bean里的属性userDao不可法,那你就检查检查看看啊

解决方案三:

http://blog.csdn.net/column/details/springlearning.html

解决方案四:

Error creating bean with name 'userAction' defined in ServletContext resource
userAction注入的有问题

解决方案五:

不写getter/setter方法直接用注解方式自动注入最方便

时间: 2024-10-29 16:37:47

spring-【新手学习Spring】报错了,根本看不懂。的相关文章

java-编写易宝支付报错,报错信息看不懂,求大神

问题描述 编写易宝支付报错,报错信息看不懂,求大神 com.yeepay.merchant.InvalidParamException: invalid param, name[hmac] value[54ae8ae84065be5c1fb90bbd3e4e71cc] 这是报错的信息,根据网上一个易宝文档写的,运行后就这样了.求大神!! 解决方案 按照错误提示来说是,merchant的无效参数导致的. name[hmac] value[54ae8ae84065be5c1fb90bbd3e4e71

struts-这个报错完全看不懂在说什么,求大神解答

问题描述 这个报错完全看不懂在说什么,求大神解答 Http status: 200 OKajaxOptions: parsererrorthrownError: SyntaxError: Unexpected token <Struts Problem ReportStruts has detected an unhandled exception: Messages: net.sf.ezmorph.Morphernet/sf/ezmorph/MorpherFile: org/apache/ca

cocos-lua在android上面运行出现这个报错,看不懂

问题描述 cocos-lua在android上面运行出现这个报错,看不懂 解决方案 从字面上理解,缺少.so文件 .so文件是类似.jar包的一个文件资源库,不过.so文件好像要更强大一些,啥都看不见. 解决方案二: 在libs文件夹中有存放的.so文件,使用c写的,好像是数据库文件还是一个脚本文件,我忘记了,你没有把那个东西也复制进来

php-我是新手百度找到的答案我看不懂。

问题描述 我是新手百度找到的答案我看不懂. php 上传文件(简历类文件),怎么制作,前端我写好了 但是怎么上传到我的站点中呢? 解决方案 <?php move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $_FILES["file"]["name"]); //移动到upload下 ?>

环信发送透传消息,报的错误看不懂,who can help me??

问题描述 错误信息: 解决方案 你是有这个创建消息体,不加map,这样创建试一试看下EMCmdMessageBody cmdBody = new EMCmdMessageBody(action);

Java新手如何学习Spring、Struts、Hibernate三大框架?(转)

整理知乎大牛答案: 1.入门看文档(blog,书籍等等),深入理解配置文件的含义(Spring.Struts.Hibernate); 2.遇到问题,自己动手解决,如果解决了,为什么这样解决?(凡事总问个为什么) 3.具体到hibernate的入门, 首先还是先要学会数据库, JDBC, 设计模式, 这些都是基础. 我的个人理解:凡事总问为什么,很关键,这是入门也是以后进一步发展的基础. 具体新手学习视频资料可以参考看看网上的视频教程,但理念必须在入门之前建立起来. 如果你是个老师(Java工程师

spring新手配置一个bean使用构造注入constructor-arg总是报错

问题描述 spring新手配置一个bean使用构造注入constructor-arg总是报错 spring新手求助! 最简单的配置了一个bean, Way里有一个构造方法 public Way(int num) { this.num = num; } 然后总是报下面错: 信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@67b6d4ae:

TDDL与Spring Boot集成Version报错——跟踪与解决

先说背景:公司采用diamond+tddl,这套技术来做web管理.本人处于好奇率先体验了下spring-boot,于是就有了spring-boot+tddl的组合.但是jar包上线后,屡屡发现一条error日志不痛不痒的出现在日志文件中,处于程序员的本能,怎么能允许error日志出现在我的系统中呢! 于是,展开了一段tddl与spring-boot的爱恨之旅... 挣扎期 首先看错误提示: 2017-09-27 11:15:58,428 [main] ERROR com.taobao.tddl

spring cloud学习填坑笔记

最近在学习spring cloud,由于学习资料具有普遍性,部分应个人原因导致的小细节问题,往往很难找到解决的办法.这特别记录一下自己遇到的一些问题. 一.eureka-server加入security做基础访问控制报错Batch update failure with HTTP status code 401; discarding 1 replication tasks 详细错误如下: 场景交代: eureka-server程序加入security后,启动程序日志是OK的,在没有其他eure