这个applicationContext.xml为:
 <bean id="bean1" class="com.aoxun.spring.Bean1">
   <property name="Strvalue" value="Hello"/>
   <property name="Intvalue" value="123"/>
   <property name="ListvalueList">
    <list>
         <value>list1</value>
        <value>list2</value>
    </list>
   </property>
   
   <property name="valueSet">
    <set>
        <value>set1</value>
        <value>set2</value>
    </set>
   </property>
   
   <property name="Arrayvalue">
    <list>
         <value>array1</value>
         <value>array2</value>
     </list>
   </property>
   
    <property name="MapvalueMap">
    <map>
         <entry key="k1" value="v1"/>
         <entry key="k2" value="v2"/>
     </map>
   </property>
Bean.java为:
public class Bean1 {
private  String strvalue;
private  int intvalue;
private  List listvalue;
private  Set setvalueSet;
private  String[] arrayvalue;
private  Map mapvalueMap;
public String getStrvalue() {
return strvalue;
}
public void setStrvalue(String strvalue) {
this.strvalue = strvalue;
}
public int getIntvalue() {
return intvalue;
}
public void setIntvalue(int intvalue) {
this.intvalue = intvalue;
}
public List getListvalueList() {
return listvalue;
}
public void setListvalueList(List listvalueList) {
this.listvalue = listvalueList;
}
public Set getSetvalueSet() {
return setvalueSet;
}
public void setSetvalueSet(Set setvalueSet) {
this.setvalueSet = setvalueSet;
}
public String[] getArrayvalue() {
return arrayvalue;
}
public void setArrayvalue(String[] arrayvalue) {
this.arrayvalue = arrayvalue;
}
public Map getMapvalueMap() {
return mapvalueMap;
}
public void setMapvalueMap(Map mapvalueMap) {
this.mapvalueMap = mapvalueMap;
}
错误为:
[org.springframework.context.support.ClassPathXmlApplicationContext] - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@ae000d: display name [org.springframework.context.support.ClassPathXmlApplicationContext@ae000d]; startup date [Tue Dec 08 00:25:14 CST 2009]; root of context hierarchy
[org.springframework.beans.factory.xml.XmlBeanDefinitionReader] - Loading XML bean definitions from class path resource [applicationContext.xml]
[org.springframework.context.support.ClassPathXmlApplicationContext] - Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@ae000d]: org.springframework.beans.factory.support.DefaultListableBeanFactory@763f5d
2009-12-08 00:25:14,765 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@763f5d: defining beans [bean1]; root of factory hierarchy
2009-12-08 00:25:14,812 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@763f5d: defining beans [bean1]; root of factory hierarchy

解决方案 »

  1.   

    哪里有错误?那些都是 INFO 信息,不是错误信息啊
      

  2.   

    是否忘了写<bean>的结束标签
      

  3.   

    我怎么觉得属性的name应该和bean中的属性对应上吧,我是说大小写应该对应上。
      

  4.   

    <bean>没有结束标签,再者<bean id="bean1" class="com.aoxun.spring.Bean1"> 
      <property name="Strvalue" value="Hello"/> 
      <property name="Intvalue" value="123"/> 
      <property name="ListvalueList"> 
        <list> 
            <value>list1 </value> 
            <value>list2 </value> 
        </list> 
      </property> 
      
      <property name="valueSet"> 
        <set> 
            <value>set1 </value> 
            <value>set2 </value> 
        </set> 
      </property> 
      
      <property name="Arrayvalue"> 
        <list> 
            <value>array1 </value> 
            <value>array2 </value> 
        </list> 
      </property> 
      
        <property name="MapvalueMap"> 
        <map> 
            <entry key="k1" value="v1"/> 
            <entry key="k2" value="v2"/> 
        </map> 
      </property> 
    标红的地方与setter方法不一致,大小写问题
      

  5.   

    我全部信息贴出来了,cause by 后面的内容贴出来啊,这全是info级别的信息看不出啥
      

  6.   

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bean1' defined in class path resource [applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'valueSet' of bean class [com.aoxun.spring.Bean1]: Bean property 'valueSet' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'valueSet' of bean class [com.aoxun.spring.Bean1]: Bean property 'valueSet' 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:793)
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
    at com.aoxun.spring.InjectionTest.setUp(InjectionTest.java:16)
    at junit.framework.TestCase.runBare(TestCase.java:125)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:208)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      

  7.   

    这是我的错误,bean我改了大小写:
     <bean id="bean1" class="com.aoxun.spring.Bean1">
       <property name="strvalue" value="Hello"/>
       <property name="intvalue" value="123"/>
       <property name="listvalueList">
        <list>
             <value>list1</value>
            <value>list2</value>
        </list>
       </property>
       
       <property name="valueSet">
        <set>
            <value>set1</value>
            <value>set2</value>
        </set>
       </property>
       
       <property name="arrayvalue">
        <list>
             <value>array1</value>
             <value>array2</value>
         </list>
       </property>
       
        <property name="mapvalueMap">
        <map>
             <entry key="k1" value="v1"/>
             <entry key="k2" value="v2"/>
         </map>
       </property>
       </bean>
    大家帮忙看看!
      

  8.   

    Bean property 'valueSet' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter? valueSet的get,set不对,看看你的程序