Avatar of Nika Gudge
Nika Gudge
Flag for United States of America

asked on 

Spring framework: how to use class instance in spring bean as property?

Below is the error that it is not able to find setter for private Data instance. Can this member variable have getters and setters?

public class Employee {
 
    private int empId;
    private String name;
    private Data instance; —— class instance


    <bean id="testid" class=“com.UpdateRecords"></bean>
    <util:list id=“testList" value-type="ServiceBase">
        <bean id=“service" class=“ServiceImpl">
            <property name="instance" ref="testid"/>
        </bean>
    </util:list>


Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'instance' of bean class

 Bean property 'instance' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
JavaJava EE

Avatar of undefined
Last Comment
Nika Gudge

8/22/2022 - Mon