时间:2021-07-01 10:21:17 帮助过:34人阅读
2、就2个注解,2个属性
package com.bw.entity; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; @Document(indexName = "week",type = "week02") public class Student { @Id private String sid; private String sname; private String pwd; public String getSid() { return sid; } public void setSid(String sid) { this.sid = sid; } public String getSname() { return sname; } public void setSname(String sname) { this.sname = sname; } public String getPwd() { return pwd; } public void setPwd(String pwd) { this.pwd = pwd; } public Student() { super(); // TODO Auto-generated constructor stub } public Student(String sid, String sname, String pwd) { this.sid = sid; this.sname = sname; this.pwd = pwd; } @Override public String toString() { return "Student [sid=" + sid + ", sname=" + sname + ", pwd=" + pwd + "]"; } }
配置
server: port: 9007 spring: application: name: tensquare‐search #指定服务名 data: elasticsearch: cluster-nodes: 127.0.0.1:9300
依赖
<!-- es的依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency>
8、2 es数据库的使用
标签:get struct boot ons elastic cat sid string ted