错误提示:org.springframework.beans.NotWritablePropertyException:Invalid property

本文解决了一个常见的Java编程问题,即由于get/set方法命名错误导致的NotWritablePropertyException异常。通过一个具体案例,详细介绍了如何检查和修正命名错误,确保属性正确封装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

错误原因:get/set方法写错 

java对象中没有把属性进行正常封装的异常,即NotWritablePropertyException

原命名是UserDaoImpl,自己写set方法时写成了setUserDaoImpl,这时只要把原先写好的get/set方法删掉,重新来一遍就好了。

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'httpInvokerConfig': Unsatisfied dependency expressed through field 'appMerchantService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appMerchantDec' defined in ServletContext resource [/WEB-INF/tpaic-auto-net-servlet.xml]: Cannot resolve reference to bean 'dispatchService' while setting bean property 'dispatch'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dispatchService' defined in ServletContext resource [/WEB-INF/tpaic-auto-net-servlet.xml]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.tpaic.nonmotor.biz' defined in class path resource [com/tpaic/nonmotor/biz/beanRefContext.xml]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.context.support.ClassPathXmlApplicationContext]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brandAutoTypeService' defined in class path resource [com/tpaic/nonmotor/biz/brand-service-context.xml]: Cannot resolve reference to bean 'contractBoSupport' while setting bean property 'contractBoSupport'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'contractBoSupport' defined in class path resource [com/tpaic/nonmotor/biz/service-bo.xml]: Cannot resolve reference to bean 'inquireDetailService' while setting bean property 'inquireDetailService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inquireDetailService' defined in class path resource [com/tpaic/nonmotor/biz/service-context-part.xml]: Cannot resolve reference to bean 'inquireDetailBoService' while setting bean property 'inquireDetailBoService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'inquireDetailBoService' defined in class path resource [com/tpaic/nonmotor/biz/service-bo.xml]: Cannot resolve reference to bean 'applyPolicyBo' while setting bean property 'applyPolicyBo'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applyPolicyBo' defined in class path resource [com/tpaic/nonmotor/biz/service-bo.xml]: Cannot resolve reference to bean 'commonParameterSupport' while setting bean property 'common'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'commonParameterSupport' defined in class path resource [com/tpaic/nonmotor/biz/service-context-part.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'aggregatedSearchService' of bean class [com.tpaic.nonmotor.biz.util.CommonParameterSupport]: Bean property 'aggregatedSearchService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
06-11
`java.lang.ClassNotFoundException: org.springframework.beans.factory.config.EmbeddedValueResolver` 和 `java.lang.NoClassDefFoundError: org.springframework.beans.FatalBeanException` 是Spring框架中常见的运行时异常,它们通常发生在尝试加载或初始化某些Spring组件(如bean)时找不到所需的类。 1. **ClassNotFoundException**: 这表明Java虚拟机(JVM)在启动时无法找到指定的类。在这个例子中,意味着Spring容器试图实例化`EmbeddedValueResolver`这个类,但找不到该类。这可能是因为类路径(classpath)配置错误,没有包含相关的jar包,或者类名拼写有误。 解决这个问题的步骤通常是: - 检查类路径:确保包含了`org.springframework.beans.factory.config.EmbeddedValueResolver`所在的jar文件。 - 检查导入语句:确认你的项目中有正确的依赖声明,比如在pom.xml(Maven)或build.gradle(Gradle)中引入了Spring框架及其相关的模块。 - 如果是maven项目,检查是否有`<scope>`标签,确保不是只在测试阶段才包含这个依赖。 2. **NoClassDefFoundError**: 这种错误更严重,它是在应用程序运行时抛出的,表明在应用启动后发现了一个之前存在的类定义缺失。`FatalBeanException`是`NoClassDefFoundError`的一种特殊情况,可能是由于类加载失败导致的Spring Bean创建失败。 如果TellersDao类依赖于`org.springframework.beans.FatalBeanException`,那么需要确保在部署环境中,所有依赖的Spring库都被正确地打包和访问到。 解决此类问题的方法包括: - 确认生产环境和开发环境使用的类路径完全一致。 - 检查部署时是否遗漏了必要的JAR文件,特别是那些只在生产环境中使用的依赖。 - 如果是Maven项目,检查是否有`provided`或`runtime` scope的依赖,这些依赖可能会在构建阶段自动排除,但在运行时需要手动添加。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值