I have a Spring Boot application and I'm trying to pass a property from application.properties as a parameter annotation within Entity class like that:
@Entity
public class Entity{
@Id
@SequenceGenerator(name = "entity_id_seq", sequenceName = "entity_id_seq", initialValue = "${start-seq}")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "dish_id_seq")
private int id;
And my application.properties have:
start-seq=100000
But it doesn't compile saying "incompatible types: java.lang.String cannot be converted to int" not recognizing expression. Also I tried to pass this property with @Value annotation to a variable like that:
@Value("${start-seq}")
private int startSeq;
But the variable is always 0. I do have following annotations before my config class, but it still doesn't work:
@Configuration
@EnableConfigurationProperties
@PropertySources({
@PropertySource("classpath:application.properties")
})
Am I missing something?