gpt4 book ai didi

Spring Boot、Hibernate 搜索属性

转载 作者:太空宇宙 更新时间:2023-11-04 09:42:34 25 4
gpt4 key购买 nike

使用 Spring Boot 时如何提供 Hibernate Search 参数?

...
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

它不关心我提供什么。始终应用默认设置。

我认为下面的代码没有任何处理与 Hibernate Search 相关的属性的内容。这可能是问题所在吗?

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

最佳答案

如果您输入“spring.jpa.properties”,则可以将它们放入 application.properties 文件中。在属性名称前面。

示例:

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

创建 EntityManagerFactory 后,Spring 将获取 spring.jpa.properties.* 下的所有属性并传递它们(去掉前缀)。

关于Spring Boot、Hibernate 搜索属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55801790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com