项目架构为:

Pom依赖:
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.nice</groupId>
<artifactId>spring-boot-es-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-es-test</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</option

该项目展示了如何在SpringBoot应用中整合Elasticsearch,包括Pom依赖配置、User类定义、UserService实现、EsConfig配置、UserController操作及SpringBootEsTestApplication启动设置。在应用运行后,通过http://localhost:8080/init初始化数据,使用elasticsearch-head查看,然后通过http://localhost:8080/add添加用户,并通过http://localhost:8080/findAll查询所有用户。
最低0.47元/天 解锁文章
3109

被折叠的 条评论
为什么被折叠?



