Failed to convert property value of type [java.lang.String] to required type [com.spring.first.Item] for property 'item'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [com.spring.first.Item] for property 'item': no matching editors or conversion strategy found
server.java
package com.spring.first;
public class Server {
private Item item;
private String itemName;
public Item getItem()
{
return item;
}
public String getItemName()
{
return itemName;
}
public void setItem(Item item)
{
this.item=item;
}
public void setItemName(String str)
{
this.itemName=str;
}
@Override
public String toString()
{
return "Server [item ="+item+", itemName ="+itemName+"]";
}
}
Item.java
public class Item {
private String name;
private int qty;
public String getName()
{
return name;
}
public int getQty()
{
return qty;
}
public void setName(String name)
{
this.name=name;
}
public void setQty(int x)
{
this.qty=x;
}
@Override
public String toString()
{
return "Item [ name ="+name+", Qty ="+qty+"];";
}
}
My configuration file
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="itemBean" class="com.spring.first.Item">
<property name="name" value="itemA" />
<property name="qty" value="10" />
</bean>
<bean id="serverBean" class="com.spring.first.Server">
<property name="item" value="#{itemBean}" />
<property name="itemName" value="#{itemBean.name}" />
</bean>
</beans>
I'm using Spring 2.5.6.