Spring data solr showcase @SolrDocument (solrCoreName = "...") from the property

I tried https://github.com/christophstrobl/spring-data-solr-showcase

I am trying to get the code to work in several different environments where the Solr kernel name may differ. Using a property to specify a kernel name may seem useful for this.

So, I'm trying to set @SolrDocument (solrCoreName = "...") from the property that I added to the application.properties file as follows:

@SolrDocument(solrCoreName = @Value("${solr.core}")) public class Product implements SearchableProductDefinition { private @Id @Indexed String id; private @Indexed(NAME_FIELD_NAME) String name; ... } 

but I get maven compilation error:

 .../git/spring-data-solr-showcase/src/main/java/org/springframework/data/solr/showcase/product/model/Product.java:[31,30] annotation not valid for a value of type java.lang.String 

I am new to Spring. Can I do what I'm trying to do?

Thanks in advance!

+5
source share

Source: https://habr.com/ru/post/1238778/


All Articles