gpt4 book ai didi

spring - 在 Jhipster 中设置 bonsai-elasticsearch - Heroku

转载 作者:行者123 更新时间:2023-11-29 02:49:33 25 4
gpt4 key购买 nike

在将我的 Jhipster 应用程序部署到 heroku 之后,我想将云 Elasticsearch (盆景)与 JHipster 一起使用。 Bonsai 提供以下环境变量:

$BONSAI_URL 

如何将其正确添加到 application-prod.yml 中?我一直在阅读文档并尝试将其设置为集群节点值和主机。但我有点迷路了。任何提示都非常受欢迎。

application-prod.yml

spring:
devtools:
restart:
enabled: false
livereload:
enabled: false
datasource:
url: jdbc:mysql://localhost:3306/App?useUnicode=true&characterEncoding=utf8&useSSL=false
name:
username: root
password:
hikari:
data-source-properties:
cachePrepStmts: true
prepStmtCacheSize: 250
prepStmtCacheSqlLimit: 2048
useServerPrepStmts: true
jpa:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
database: MYSQL
show_sql: false
properties:
hibernate.cache.use_second_level_cache: true
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
hibernate.cache.region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
data:
elasticsearch:
network:
host: ${BONSAI_URL}
cluster-name: VLT
cluster-nodes: localhost:9300
mail:
host: smtp.sendgrid.net
port: 587
username: ${SENDGRID_USERNAME}
password: ${SENDGRID_PASSWORD}
protocol: smtp
tls: false
auth: true
from: noreply@app.com

thymeleaf:
cache: true

liquibase:
contexts: prod

server:
port: 8080
compression:
enabled: true
mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json
min-response-size: 1024

最佳答案

我添加了 spring-boot-starter-data-jest 库来构建脚本,build.gradle:

-    compile "org.springframework.boot:spring-boot-starter-data-elasticsearch"
+ compile "com.github.vanroy:spring-boot-starter-data-jest:2.2.0.RELEASE"

在应用程序类 App.java 中添加了对 ElasticsearchAutoConfiguration 和 ElasticsearchDataAutoConfiguration 的排除:

@ComponentScan
+@EnableAutoConfiguration(exclude = {
+ ElasticsearchAutoConfiguration.class, ElasticsearchDataAutoConfiguration.class })
@EnableConfigurationProperties({ JHipsterProperties.class, LiquibaseProperties.class })
public class App {

并改变了:

import org.elasticsearch.client.Client;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.EntityMapper;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.vanroy.springdata.jest.JestElasticsearchTemplate;
+import com.github.vanroy.springdata.jest.mapper.DefaultJestResultsMapper;
+import io.searchbox.client.JestClient;

@Configuration
public class ElasticSearchConfiguration {

@Bean
- public ElasticsearchTemplate elasticsearchTemplate(Client client, Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder) {
- return new ElasticsearchTemplate(client, new CustomEntityMapper(jackson2ObjectMapperBuilder.createXmlMapper(false).build()));
+ public JestElasticsearchTemplate elasticsearchTemplate(JestClient client, Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder) {
+ return new JestElasticsearchTemplate(client, new DefaultJestResultsMapper(
+ new CustomEntityMapper(jackson2ObjectMapperBuilder.createXmlMapper(false).build())));
}

然后我添加了配置参数,文件application.yml:

+    data:
+ elasticsearch:
+ properties:
+ path:
+ home: target/elasticsearch
+ transport:
+ tcp:
+ connect_timeout: 120s
jest:
+ readTimeout: 10000
uri: ${SEARCHBOX_SSL_URL}

关于spring - 在 Jhipster 中设置 bonsai-elasticsearch - Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39623238/

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