2017-11-27 4 views
0

스프링 부트 응용 프로그램 내에서 elasticSearch 저장소를 사용하고 싶습니다. 는 내가 잠시 동안 검색했습니다 5.5.2 는, 작업 솔루션을 산출 여러 소스 아무것도하지만, 너무 많은 조합을 시도 탄성 검색 지역 실행중인 인스턴스를 가지고 있고, 지금은 에 붙어 오류 :지역 탄성 검색 인스턴스가 작동하지 않는 springboot 사용

오류 이름으로 콩을 만드는 'elasticsearchTemplate'내가 잘못하고있는 무슨

?

이 내 주요 클래스

@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class}) 
    public class Application { 

     public static void main(String[] args) { 

      Logger logger = LoggerFactory.getLogger("chapters.introduction.HelloWorld1"); 
      try 
      { 
       SpringApplication.run(Application.class, args); 
      } 
      catch(Exception e) 
      { 
       logger.info("caught an exception",e); 
      } 

     } 
} 

설정 클래스

@Configuration 
@EnableElasticsearchRepositories(basePackages = "hello") 
@ComponentScan(basePackages = {"hello"}) 
public class config { 

    @Bean 
    public NodeBuilder nodeBuilder() { 
     return new NodeBuilder(); 
    } 

    @Bean 
    public ElasticsearchOperations elasticsearchTemplate() { 
     Settings.Builder elasticsearchSettings = 
       Settings.settingsBuilder() 
         .put("http.enabled", "false") // 1 
         .put("path.data", "/home/nad/elasticsearch_data") // 2 
         .put("path.home", "/home/nad/Downloads/elasticsearch-5.5.2"); // 3 



     return new ElasticsearchTemplate(nodeBuilder() 
       .local(true) 
       .settings(elasticsearchSettings.build()) 
       .node() 
       .client()); 
    } 

} 

build.gradle 파일

group 'FirstWebServer' 
version '1.0-SNAPSHOT' 

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.8.RELEASE") 
    } 
} 

apply plugin: 'java' 
apply plugin: 'eclipse' 
apply plugin: 'idea' 
apply plugin: 'org.springframework.boot' 

jar { 
    baseName = 'gs-spring-boot' 
    version = '0.1.0' 
} 

repositories { 
    maven { url "http://repo.spring.io/milestone" } 
    mavenCentral() 
} 

sourceCompatibility = 1.8 
targetCompatibility = 1.8 

dependencies { 
    // tag::jetty[] 
    compile("org.springframework.boot:spring-boot-starter-web") { 
     exclude module: "spring-boot-starter-tomcat" 
    } 
    compile("org.springframework.boot:spring-boot-starter-jetty") 
    // end::jetty[] 
    // tag::actuator[] 
    compile("org.springframework.boot:spring-boot-starter-actuator") 
    // end::actuator[] 
    //compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-elasticsearch', version: '1.2.5.RELEASE' 
    compile group: 'org.springframework.data', name: 'spring-data-elasticsearch', version: '3.0.1.RELEASE' 
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version: '2.0.0.M6', ext: 'pom' 
    compile("org.springframework.boot:spring-boot-starter-data-jpa") 
    compile group: 'org.projectlombok', name: 'lombok', version: '1.16.18' 

    testCompile("junit:junit") 
} 

톤 무엇이다 그분은 적절한 구성 방법을 원하십니까? 일부 예제는 application.properties 구성을 보여줍니다. 일부는 아닙니다. 무엇 호환성 만 2 * 이하를 elasticsearch 일부 쇼 에 대해, 일부는

는 당신의 도움을 주셔서 감사합니다 :(그 5

그것 정말 혼란 말했다

답변

0

Elasticsearch 5.x를 사용하려면 Spring Data release Kay (이미 릴리스 됨)가 필요합니다.이 릴리스는 곧 출시 될 Spring Boot 2의 일부입니다. 현재 유일한 옵션은 최신 Spring Boot 2 빌드를 사용하여 안정적인 릴리스.

어떤 사람들은 Spring Data Kay를 Spring 부트 1.5와 함께 사용해 보았지만, 의존성 지옥에서 끝났습니다. 아마도 구석을 돌면 스프링 부트 2와 함께 고통을 감수 할 가치가 없을 것입니다.