Exception in thread "main"
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'boss' defined in class path resource
[xiao/lei/entity/beans.xml]: Error setting property values; nested
exception is
org.springframework.beans.NotWritablePropertyExcep tion: Invalid
property 'office' of bean class [xiao.lei.entity.Boss]: Bean
property 'office' 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.AbstractAutowireCapableB eanFactory.applyPropertyValues(AbstractAutowireCapableB eanFactory.java:1353)
at
org.springframework.beans.factory.support.AbstractAutowireCapableB eanFactory.populateBean(AbstractAutowireCapableB eanFactory.java:1076)
at
org.springframework.beans.factory.support.AbstractAutowireCapableB eanFactory.doCreateBean(AbstractAutowireCapableB eanFactory.java:517)
at
org.springframework.beans.factory.support.AbstractAutowireCapableB eanFactory.createBean(AbstractAutowireCapableB eanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegi stry.getSingleton(DefaultSingletonBeanRegi stry.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.DefaultListableBeanFacto ry.preInstantiateSingletons (DefaultListableBeanFacto ry.java:574)
at
org.springframework.context.support.AbstractApplicationConte xt.finishBeanFactoryInitial ization(AbstractApplicationConte xt.java:895)
at
org.springframework.context.support.AbstractApplicationConte xt.refresh(AbstractApplicationConte xt.java:425)
at
org.springframework.context.support.ClassPathXmlApplicationC ontext.(ClassPathXmlApplicationC ontext.java:139)
at
org.springframework.context.support.ClassPathXmlApplicationC ontext.(ClassPathXmlApplicationC ontext.java:93)
at
xiao.lei.test.AnnoloCTest.main(AnnoloCTest.java:16)
Caused by: org.springframework.beans.NotWritablePropertyExcep tion:
Invalid property 'office' of bean class [xiao.lei.entity.Boss]:
Bean property 'office' 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:1016)
at
org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:896)
at
org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractPropertyAccessor .java:76)
at
org.springframework.beans.AbstractPropertyAccessor .setPropertyValues(AbstractPropertyAccessor .java:58)
at
org.springframework.beans.factory.support.AbstractAutowireCapableB eanFactory.applyPropertyValues(AbstractAutowireCapableB eanFactory.java:1350)
... 13
more
错误原因是:Boss类中缺少属性的set/get方法
public class Boss {
private
Office office;
@Override
public
String toString() {
return "office:" + office;
}
}
Caused by: org.springframework.beans.NotWritablePropertyExcep
错误原因是:Boss类中缺少属性的set/get方法
public class Boss {
}