So I have some custom POJO. I want any time when I instantiate that object thorough empty constructor to have its filed fee
initialized to some preset value from application.properties
.
In my application-prod.properties
:
fee=1500
My POJO class:
public class PenaltyWithNoInvoiceDto {
private int penatltyId;
private int number;
private String projectName;
@Value("${fee}")
private float fee;
public PenaltyWithNoInvoiceDto() {
}
public PenaltyWithNoInvoiceDto(int penatltyId, int number, String projectName) {
super();
this.penatltyId = penatltyId;
this.number = number;
this.projectName = projectName;
}
}
In my @Service
class, I'm instantiating PenaltyWithNoInvoiceDto
with empty constructor. But when I print fee
field, I get zero.
How do I make this field to have value of 1500, I get that value from application-prod.properties
?