报错代码:
十一月 21, 2022 10:32:01 下午 org.springframework.context.support.AbstractApplicationContext refresh 警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'student' defined in class path resource [applicationcontext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.LinkedHashMap' to required type 'java.util.Map' for property 'teacherMap'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'com.atguigu.spring.pojo.Teacher' for property 'teacherMap[name]': no matching editors or conversion strategy found org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'student' defined in class path resource [applicationcontext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.LinkedHashMap' to required type 'java.util.Map' for property 'teacherMap'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'com.atguigu.spring.pojo.Teacher' for property 'teacherMap[name]': no matching editors or conversion strategy found
解决方案:
在写application.xml文件的时候,没有注意teacherMap的value值是引用数据类型。
修改后: