本文转自:乐字节文章主要讲解:如何配置Elasticsearch和准备工作环境IntelliJIDEAElasticsearch的安装过程这里不再赘述。本文使用Elasticsearch集群环境,已安装IK中文分词器。下图为elasticsearch-head插件显示的集群信息(浏览器可直接安装插件连接)。SpringBoot创建项目使用SpringInitializr初始化SpringBoot项目,添加SpringWeb、SpringDataElasticsearch、MySQL、MyBatis、Lombok。配置文件application.yml配置了MySQL、Elasticsearch、MyBatis的相关信息。spring:#数据源datasource:driver-class-name:com.mysql.cj.jdbc.Driverurl:jdbc:mysql://localhost:3306/example?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=falseusername:rootpassword:123456#elasticsearchelasticsearch:rest:uris:192.168.10.10:9200,192.168.10.11:9200,192.168.10.12:9200mybatis:configuration:map-underscore-to-camel-case:true#开启驼峰映射启动类启动类添加Mapper接口扫描。packagecom.example;importorg.mybatis.spring.annotation.MapperScan;importorg.springframework.boot.SpringApplication;importorg.springframework.boot.autoconfigure.SpringBootApplication;@MapperScan("com.example.mapper")//映射器接口扫描@SpringBootApplicationpublicclassSearchDemoApplication{publicstaticvoidmain(String[]args){SpringApplication.run(SearchDemoApplication.class,args);}}Front-end将我给大家准备的前端资源文件添加到static目录下的项目resources目录下。获取前端资源文件公众号:《乐字节》,发送999并使用CDN在list.html中添加Vue和Axios,避免下载文件的过程。感谢大家的观看和支持,下一期会讲解Elasticsearch项目开发过程
