Question - What do you understand by @Required annotation?
Answer -
@Required is applied to bean property setter methods. This annotation simply indicates that the affected bean property must be populated at the configuration time with the help of an explicit property value in a bean definition or with autowiring. If the affected bean property has not been populated, the container will throw BeanInitializationException.
For example:
- public class Employee
- {
- private String name;
- @Required
- public void setName(String name)
- {this.name=name; }
- public string getName()
- { return name; }
- }