2016-09-21 17 views
3

私のJhipsterアプリケーションをherokuにデプロイした後、JHipsterでcloud elasticsearch(Bonsai)を使いたいと思います。盆栽は以下のenv変数を提供します:Jhipster - Herokuでの盆栽 - elasticsearchの設定

$BONSAI_URL 

これはapplication-prod.ymlでどのように正しく追加されますか? 私はドキュメントを読んでいて、クラスタノードの値とホストとして設定しようとしています。しかし、私は少し失われています。どんなヒントも大歓迎です。

アプリケーション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: [email protected] 

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 
+0

あなたがこの問題の解決策を見つけますか? –

答えて

4

は、私は、スクリプトを構築するためにspring-boot-starter-data-jestライブラリを追加し、build.gradle:

​​

を追加しましたが、アプリケーションクラスApp.javaにElasticsearchAutoConfigurationとElasticsearchDataAutoConfigurationため除外:

@ComponentScan 
[email protected](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ファイル、configuraitonパラメータを追加しました:

+ data: 
+  elasticsearch: 
+   properties: 
+    path: 
+     home: target/elasticsearch 
+    transport: 
+     tcp: 
+      connect_timeout: 120s 
     jest: 
+   readTimeout: 10000 
      uri: ${SEARCHBOX_SSL_URL} 
関連する問題