Issue
I am trying to add @Required
Annotation to my bean but complier says it's deprecated.
public class Product {
private String id;
public String getId() {
return id;
}
@Required
public void setId(String id) {
this.id = id;
}
}
Is there a different annotation for this?
Solution
Read the documentation:
Deprecated as of 5.1, in favor of using constructor injection for required settings (or a custom
InitializingBean
implementation).
public class Product {
private String id;
public Product(String id) {
this.id = id;
}
public String getId() {
return id;
}
Answered By - Andreas