I have tried to initialize setter method from context file.But it isn't working as expected.
//setter method
public class Service {
private long Id=0;
public long getId() {
return Id;
}
public void setId(long Id) {
this.Id = Id;
}
}
//calling method
public class test {
//...source code
Service sercvi = new Service();
System.out.println("******************ID"+sercvi.getId());
..................................
}
Context.xml
..........................................
..........................................
<bean id="Service" class="com.test.Service.Service" >
<property name="Id" value="100"/>
</bean>
...........................................
..........................................
Here goes loading context file in web.xml file web.xml
...............................
....................
<!-- Spring load context.xml - -->
<context-param>
<param-name>contextLocation</param-name>
<param-value>/WEB-INF/Context.xml</param-value>
</context-param>
If i run the application it always return 0 value for id but i have initalized 100 in context.xml. Why that value is not retrieved ? How to initlialize setter method value from context file? Also how to retrieve those value?
How to resolve this error?