Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot, Hibernate Search properties

How to provide Hibernate Search parameters when using Spring Boot?

...
spring.datasource.driverClassName=org.postgresql.Driver

hibernate.search.jmx_enabled=true
hibernate.search.default.directory_provider=filesystem
hibernate.search.generate_statistics=true
hibernate.search.lucene_version=LUCENE_CURRENT
hibernate.search.default.indexBase=/mypath-to-index

It does not care what I provide. Default settings always get applied.

I think below code does not have anything to process properties related to Hibernate Search. Can that be the issue?

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java

like image 998
retromuz Avatar asked Aug 24 '14 17:08

retromuz


1 Answers

You can put them in the application.properties file if you put "spring.jpa.properties." in front of the property names.

Example:

spring.jpa.properties.hibernate.search.jmx_enabled=true
spring.jpa.properties.hibernate.search.default.directory_provider=filesystem
spring.jpa.properties.hibernate.search.generate_statistics=true
spring.jpa.properties.hibernate.search.lucene_version=LUCENE_CURRENT
spring.jpa.properties.hibernate.search.default.indexBase=/mypath-to-index

Spring will take any properties under spring.jpa.properties.* and pass them along (with the prefix stripped) once the EntityManagerFactory is created.

like image 129
John A Avatar answered Sep 30 '22 18:09

John A