zoukankan      html  css  js  c++  java
  • spring创建错误:Error creating bean with name 'hello' defined in class path resource [application.xml]

      spring创建错误:Error creating bean with name 'hello' defined in class path resource [application.xml]

    错误提示:

    警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hello' defined in class path resource [application.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sQii' of bean class [com.spring_test.Hello]: Bean property 'sQii' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hello' defined in class path resource [application.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'sQii' of bean class [com.spring_test.Hello]: Bean property 'sQii' 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:1736)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1444)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:895)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85)
        at test.Test_hou_1.main(Test_hou_1.java:11)
    Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'sQii' of bean class [com.spring_test.Hello]: Bean property 'sQii' 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.createNotWritablePropertyException(BeanWrapperImpl.java:243)
        at org.springframework.beans.AbstractNestablePropertyAccessor.processLocalProperty(AbstractNestablePropertyAccessor.java:426)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:278)
        at org.springframework.beans.AbstractNestablePropertyAccessor.setPropertyValue(AbstractNestablePropertyAccessor.java:266)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:97)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:77)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1732)
        ... 13 more

    不要说了,在application.xml的时候忘记给实现类创建get()来获取对象了,所以直接GG。

    解决方法:只需要在测试类中加上get和对应的set方法就好了

  • 相关阅读:
    (一)Python入门-3序列:04列表-元素删除的3种方式-删除本质是数组元素拷贝
    (一)Python入门-3序列:05列表-元素的访问-元素出现次数统计-成员资格判断
    Java学习笔记_180704_final和static关键字
    Java学习笔记_180702_基本类型和引用类型作为参数传递特性
    Java学习笔记_180702_面向对象编程
    如何手动实现整型数值60的二进制到十六进制的转换
    Java学习笔记_180627_循环控制语句
    兔子生兔子问题(斐波那契数列)
    Java学习笔记_180625_基础语法
    ubuntu和win10双系统,用ubuntu引导win10启动
  • 原文地址:https://www.cnblogs.com/instead-everyone/p/13863683.html
Copyright © 2011-2022 走看看