retromuz
retromuz

Reputation: 799

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

Upvotes: 4

Views: 6245

Answers (2)

John A
John A

Reputation: 366

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.

Upvotes: 25

retromuz
retromuz

Reputation: 799

Got it working.

Put another property file named "hibernate.properties" inside src/main/resources with below content.

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

Upvotes: 3

Related Questions