Stereotype Annotation(@value, @component)

@Component, @Value
@Component is use to declare object of class like bean declaration, and bean name can
specify in @Component("here").
Base class should be specify through context:
<context:component-scan base-package="com."/>

IoC will scan the base package and its sub package as well.
@Value is used to give the value directly. For eg:
For Collection, declare in xml file with util and use id #{id} inside @Value("#{id}")
@Component
public class Student {
@Value("H")
private String studentName;
@Value("Ktm")
private String city;
@Value("#{temp}")
private List<String> address;
}



Comments

Popular posts from this blog