Spring Boot + Spring Data + Elasticsearch instance

Source: Internet
Author: User
Tags xmlns elastic search
Spring Boot + Spring Data + Elasticsearch instance

In this article, we'll discuss "how to create a spring Boot + spring Data + Elasticsearch sample".


The tools used in this article:

Spring Boot 1.5.1.RELEASE

Spring Boot Starter Data Elasticsearch 1.5.1.RELEASE

Spring Data Elasticsearch 2.10.RELEASE

Elasticsearch 2.4.4

Maven

Java 8


Attention
Springboot 1.5.1.RELEASE and Spring Data Elasticsearch 2.10.RELEASE only support Elasticsearch 2.4.0. They do not support the latest version of the Elasticsearch 5.x version.

Additional: Spring boot is currently available to operate ES with spring data. However, there are strict requirements on the version. (This sentence is not the original text, reduce the pit)


1. Project structure

A standard MAVEN project structure.



2. Project Dependencies

Configure Spring-boot-starter-data-elasticsearch for spring Data ElasticSearch application.


Pom.xml

<?xml version= "1.0" encoding= "UTF-8"?>
<project xmlns= "http://maven.apache.org/POM/4.0.0"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "http://maven.apache.org/POM/4.0.0
Http://maven.apache.org/xsd/maven-4.0.0.xsd ">
<modelVersion>4.0.0</modelVersion>

<artifactId>springboot-springdata-elasticsearch-example</artifactId>
<packaging>jar</packaging>
<url>https://www.mkyong.com</url>
<version>1.0</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
</parent>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<!--Runtime, for Embedded Elasticsearch,
Comment this if connect to external elastic search server-->
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<scope>runtime</scope>
</dependency>

</dependencies>

<build>
<plugins>
<!--package as a executable Jar/war--
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactid>spring-boot-maven-plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.