我遇到了下面给出的错误:
堆栈跟踪
Apr 16,2014 12:21:23 PM org.springframework.beans.factory.xml.XmlBeanDeFinitionReader loadBeanDeFinitionsINFO: Loading XML bean deFinitions from class path resource [beans.xml]Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'collectionsWithProps' defined in class path resource [beans.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: InvalID property 'adminEmails' of bean class [com.student.spring.impl.CollectionsWithProps]: Bean property 'adminEmails' 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:1396) at org.springframework.beans.factory.support.AbstractautowireCapablebeanfactory.populateBean(AbstractautowireCapablebeanfactory.java:1118) 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.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 com.student.spring.test.MyTest.main(MyTest.java:26)Caused by: org.springframework.beans.NotWritablePropertyException: InvalID property 'adminEmails' of bean class [com.student.spring.impl.CollectionsWithProps]: Bean property 'adminEmails' 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:1064) at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:924) 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:1393) ... 8 more
这是我的MyTest.java
package com.student.spring.test;import java.util.PropertIEs;import org.springframework.beans.factory.beanfactory;import org.springframework.beans.factory.xml.Xmlbeanfactory;import org.springframework.core.io.ClassPathResource;import org.springframework.core.io.Resource;import com.student.spring.impl.CollectionsWithProps;@SuppressWarnings("deprecation")public class MyTest { public static voID main(String[] args) { Resource resource = new ClassPathResource("beans.xml"); beanfactory beanfactory = new Xmlbeanfactory(resource); CollectionsWithProps cwp = (CollectionsWithProps) beanfactory .getBean("collectionsWithProps"); System.out.println(cwp); }}
这是CollectionsWithProps.java
package com.student.spring.impl;import java.util.PropertIEs;public class CollectionsWithProps { private PropertIEs emails=null; public PropertIEs getEmails() { return emails; } public voID setEmails(PropertIEs emails) { this.emails = emails; } public String toString(){ return "College [Props=" + emails + "]"; }}
这是我的beans.xml
最佳答案在beans.xml中,您尝试设置CollectionsWithProps的字段adminEmails.但是该类没有该字段,它具有电子邮件字段.
修复beans.xml以使用电子邮件而不是adminEmails,或修复CollectionsWithProps的源代码将电子邮件重命名为adminEmails(以及getter和setter)
总结以上是内存溢出为你收集整理的java – org.springframework.beans.NotWritablePropertyException:bean类的属性’adminEmails’无效全部内容,希望文章能够帮你解决java – org.springframework.beans.NotWritablePropertyException:bean类的属性’adminEmails’无效所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)