How to assign annotation value from application.properties in Spring Boot?

jeeva :

I have an entity/model with discriminator formula and now I'm assigning a discriminator formula like the following sample,

@Entity
@DiscriminatorFormula("type")
class Student {
    // code
}

In the same case, how can I assign discriminator value from application.properties in Spring Boot?

SakshamB :

The expression in the class level annotation should be a constant, i.e., final and static. What you are trying to achieve is not possible. The best you can do is read it from a constant file rather than application.properties.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=432817&siteId=1
Recommended