Я пытаюсь настроить плагин ElasticSearch с Grails 3, используя mongodb.как это сделать? - PullRequest
0 голосов
/ 05 декабря 2018

Я пытаюсь настроить плагин ElasticSearch с Grails 3, используя mongodb.Я не могу настроить.

Я взял ссылку из документа: https://puneetbehl.github.io/elasticsearch-grails-plugin/snapshot/index.html#introduction

в соответствии с указанным выше документом:

Я добавил следующие зависимости в build.gradle

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        //classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.8"
    }
}

version "0.1"
group "demo"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"

def elasticsearchVersion = '5.4.3'
ext['elasticsearch.version'] = elasticsearchVersion

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
}

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-i18n"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:mongodb"
    compile 'org.grails.plugins:spring-security-shiro:3.1.1'
    compile "org.grails.plugins:gsp"
    compile 'org.grails.plugins:quartz:2.0.13'
    compile group: 'com.itextpdf', name: 'itextpdf', version: '5.0.6'
    compile 'org.imgscalr:imgscalr-lib:4.2'
    compile "org.grails.plugins:elasticsearch:2.4.0"
    console "org.grails:grails-console"
    profile "org.grails.profiles:web"
    runtime "org.glassfish.web:el-impl:2.1.2-b03"
    runtime "com.h2database:h2"
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.8"
    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails:grails-web-testing-support"
    testCompile "org.grails.plugins:geb:1.1.2"
    testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:2.47.1"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}

bootRun {
    jvmArgs('-Dspring.output.ansi.enabled=always')
    addResources = true
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

tasks.withType(Test) {
    systemProperty "geb.env", System.getProperty('geb.env')
    systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
    systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
    systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}

assets {
    minifyJs = true
    minifyCss = true
}

application.yml

---
grails:
  plugin:
    springsecurity:
      successHandler:
        defaultTargetUrl: "/dashboard/index"
        alwaysUseDefault: true
---
grails:
  config:
    locations : [ "classpath:/usr/local/tomcat/app-config.properties"]
---
environments:
    development:
        grails:
                mongodb:
                    host: "192.168.10.158"
                    port: 27017
                    username: ""
                    password: ""
                    databaseName: "mydb"
    production:
          grails:
                mongodb:
                    host: "localhost"
                    port: 27017
                    username: ""
                    password: ""
                    databaseName: "mydb"
---
elasticSearch:
    datastoreImpl: mongoDatastore
    client:
        mode: transport
        hosts:
          - {host: 192.168.10.158, port: 9200}
    cluster.name: elasticsearch
    disableAutoIndex: false
    bulkIndexOnStartup: true

При запуске приложения выдается следующая ошибка:

 2018-12-27 10:32:33.239  INFO --- [           main] g.p.elasticsearch.ClientNodeFactoryBean  : Adding host: /192.168.10.158:9200
2018-12-27 10:32:33.663  WARN --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'auditListener': Cannot resolve reference to bean 'indexRequestQueue' while setting bean property 'indexRequestQueue'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'indexRequestQueue': Cannot resolve reference to bean 'jsonDomainFactory' while setting bean property 'jsonDomainFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jsonDomainFactory': Cannot resolve reference to bean 'domainReflectionService' while setting bean property 'domainReflectionService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'domainReflectionService': Unsatisfied dependency expressed through field 'mappingContext'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.grails.datastore.mapping.model.MappingContext' available: expected single matching bean but found 2: grailsDomainClassMappingContext,mongoMappingContext
2018-12-27 10:32:33.671  INFO --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2018-12-27 10:32:33.685  INFO --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-12-27 10:32:33.688 ERROR --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field mappingContext in grails.plugins.elasticsearch.mapping.DomainReflectionService required a single bean, but 2 were found:
        - grailsDomainClassMappingContext: defined in null
        - mongoMappingContext: defined by method 'getMappingContext' in null
...