错误信息:
Error creating bean with name 'accountService3' defined in class path resource [bean.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.lang.Object[]' to required type 'java.lang.reflect.Array[]' for property 'myArr'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'java.lang.reflect.Array' for property 'myArr[0]': no matching editors or conversion strategy found
释意这个样子:使用类路径资源[bean]中定义的名称为“accountService3”创建bean时出错。: bean初始化失败;嵌套异常是org.springframe .beans。ConversionNotSupportedException:未能转换“java.lang”类型的属性值。对象[]’ to required type ‘java.lang.reflect。数组[]‘用于属性’myArr’;嵌套异常是java.lang。**IllegalStateException:不能转换“java.lang”类型的值。字符串“to required type”java.lang.reflect。数组’ for属性’myArr[0]’?*没有找到匹配的编辑器或转换策略
代码处:(源代码)
<!--复杂类型的依赖注入 bean-->
<bean id="accountService3" class="com.shiyaxin.service.impl.AccountServiceImpl3">
<property name="myArr">
<array> **提示就是这个数组注入错误啦**
<value>阿里</value>
<value>小龙</value>
<value>泰森</value>
</array>**提示就是这个数组注入错误啦**
</property>
对应的类参数位置
private IAccountDao accountDao = new AccountDaoImpl();
//只有构造函数是默认的才可以创建,加个参数需要加东西
//复杂类型的依赖注入,使用set把他们注入进去
private Array[]myArr; **错误我处,错误处 错误处** 数组哪有这个类型Array?
private List<String>myList;
private Set<String>mySet;
private Map<String,String> myMap;
private Properties myProp;
<property name="myMap">
<map>
<entry key="周润发">
<value>Hongkong</value>
</entry>
</map>
</property>
错误解决: private Array[]myArr; 错误我处,错误处 错误处 数组哪有这个类型Array?
数组换掉这个类型就好了 String INT 都可以的