mercredi 5 août 2015

Inject Spel parameter on annotation parameter (like what is done with @Value on a field)


I'm using this annotation provided by spring-starter-elastic-searchto create a document and I would like to inject the parameter indexname dynamically:

@Entity
@Document(indexName = "myindex")
public class StockQuotation 

In another bean I have successfully done that by using @Valueon a field:

@Value("${elasticsearch.index.name}")
public String indexName;

However, I have tried to inject it in the same way in the annotation and the translation is not done:

@Entity
@Document(indexName = "${elasticsearch.index.name}")
public class StockQuotation

As I get this exception:

Caused by: org.elasticsearch.indices.IndexMissingException: [${elasticsearch.index.name}] missing

What would be the appropriate approach to do this?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire