Gaurav
Gaurav

Reputation: 31

How to get attributes value inside spring annotations from properties fle

I have this code in my Entity class

@Table (schema= "xyz")

now I wish to read this xyz from some properties file. How can I do that?

something like this

@Table(schema= ${property.schema})

Upvotes: 1

Views: 418

Answers (1)

Angel Villalain
Angel Villalain

Reputation: 595

You can't do that. A java annotation is simply metadata added to the source code. Once the vm runs this information can be used or discarded depending on the retention policy of the annotation. The attribute you are trying to configure must be a constant. For more info check this link.

Upvotes: 1

Related Questions