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" >
< parent>
< artifactId> foodie-dev</ artifactId>
< groupId> com.immoc</ groupId>
< version> 1.0-SNAPSHOT</ version>
</ parent>
< modelVersion> 4.0.0</ modelVersion>
< properties>
< elasticsearch.version> 7.4.2</ elasticsearch.version>
</ properties>
< artifactId> foodie-dev-search</ artifactId>
< 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>
</ dependency>
</ dependencies>
</ project>
application.yml
spring :
data :
elasticsearch :
cluster-nodes : 192.168.2.251: 9300 , 192.168.2.252: 9300 , 192.168.2.253: 9300
cluster-name : immoc- es- cluster
datasource :
type : com.zaxxer.hikari.HikariDataSource
driver-class-name : com.mysql.jdbc.Driver
url : jdbc: mysql: //192.168.2.253: 3306/immoc? useUnicode=true&characterEncoding =UTF- 8&autoReconnect =true
username : root
password : root
ElasticSearchConfig类
@Configuration
public class ElasticSearchConfig {
@PostConstruct
void init ( ) {
System. setProperty ( "es.set.netty.runtime.available.processors" , "false" ) ;
}
}