[code="java"]
package com.spdb.conf;
public class ChangeRptConf {
private String[] orgIdArray;
public String[] getOrgIdArray() {
return orgIdArray;
}
public void setOrgIdArray(String[] orgIdArray) {
this.orgIdArray = orgIdArray;
}
}
[/code]
[code="xml"]
9401
9402
[/code]
测试代码
[code="java"]
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
ChangeRptConf conf = (ChangeRptConf) ctx.getBean("changeRptConfBean");
String[] x = conf.getOrgIdArray();
for (int i = 0; i < x.length; i++) {
System.out.println(x[i]);
}
[/code]
具体报错:
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'changeRptConfBean' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.util.ArrayList] to required type [java.lang.String[]] for property 'orgIdArray'; nested exception is java.lang.IllegalArgumentException: Original must not be null
难道是bean配置有问题吗?