Pavan
Pavan

Reputation: 13

Externalize the table name to yml | Spring Boot

I am trying to get the table name from yaml file for easy changing of table names in Spring Boot project (JPA).

I tried with @Table(name="${table.name}") but it didn't work.

Can anyone please help me with the sample code and yaml file?

Upvotes: 1

Views: 651

Answers (1)

Andy Wilkinson
Andy Wilkinson

Reputation: 116091

The @Table annotation is processed by Hibernate and it doesn't provide a way to plug in custom processing of an annotation's attributes. This makes it too difficult for Spring Boot to allow you to use application properties in the attributes of @Table and any other Hibernate-processed annotation. If you're interested in learning more, this Spring Boot issue contains some more discussion about the problem and Hibernate's limitations.

Upvotes: 2

Related Questions