警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'student' defined in class path resource [s03/applicationContext.xml]: Unsatisfied dependency expressed through constructor parameter 2: Could not convert argument value of type [java.lang.String] to required type [com.jmi.pojo3.School]: Failed to convert value of type 'java.lang.String' to required type 'com.jmi.pojo3.School'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'com.jmi.pojo3.School': no matching editors or conversion strategy found
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'student' defined in class path resource [s03/applicationContext.xml]: Unsatisfied dependency expressed through constructor parameter 2: Could not convert argument value of type [java.lang.String] to required type [com.jmi.pojo3.School]: Failed to convert value of type 'java.lang.String' to required type 'com.jmi.pojo3.School'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'com.jmi.pojo3.School': no matching editors or conversion strategy found
在idea中使用spring写一个使用构造方法下标注入值的时候,出现了这个错,然后我去查找了一下,说把target删除一下就好,但是还是报这个错,我就仔细看了一下,他说我第2个参数类型不对,如下图的代码块所示,我看了一下。是我的配置文件,注入值的时候有问题。
through constructor parameter 2: Could not convert argument value of type [java.lang.String] to required type [com.jmi.pojo3.School]: Failed to convert value of type 'java.lang.String' to required type 'com.jmi.pojo3.School'
如果是引用类型,那么你这里不能使用value来注入值 ,而是使用ref来注入值,改成ref之后,再运行就可以正常运行了。在这里记录一下,这个错。