赞
踩
1.pom依赖引用
<dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>7.6.2</version> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-client</artifactId> <version>7.6.2</version> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>transport</artifactId> <version>${ elasticsearch.version}</version> </dependency> <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>7.6.2</version> </dependency> <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>x-pack-transport</artifactId> <version>${ elasticsearch.version}</version> </dependency>
2.yml 参数配置
elasticsearch:
ansy:
page-size: 7000
cluster-name: my-application
index-prefix: xz
#用户名及密码
xpack-security-user: elastic:elastic
#es集群
ips:
- ip: 127.0.0.1
port: 9200
#- ip: 127.0.0.1
# port: 9300
3.config配置获取参数
package com.example.demo.config; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import java.util.List; import java.util.Map; @Component @ConfigurationProperties(prefix = "elasticsearch.ansy") public class ElasticsearchConfig { private Map<String, String> sqls; // 数据库读取线程数 private int pThreadNum; // ES同步线程数 private int cThreadNum; //数据库读取条数 private int pageSize; //集群IP private List<Map<String,String>> ips; private String clusterName; private String timepath; //ESXpack用户名密码 private String xpackSecurityUser; //ESXpack instance.key private String xpackSslKey; //ESXpack instance.crt private String xpackSslCertificate; //ESXpack ca.crt private String xpackSslCertificateauthorities; //ESXpack xpack.security.transport.ssl.verification_mode certificate private String xpackSslVerificationmode; //ESXpack xpack.security.transport.ssl.enabled private String xpackSslEnabled; public Map<String, String> getSqls() { return sqls; } public void setSqls(Map<String, String> sqls) { this.sqls = sqls; } public int getpThreadNum() { return pThreadNum; } public void setpThreadNum(int pThreadNum) { this.pThreadNum = pThreadNum; } public int getcThreadNum() { return cThreadNum; } public void setcThreadNum(int cThreadNum) { this.cThreadNum = cThreadNum; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public List<Map<String, String>> getIps() { return ips; } public void setIps(List<Map<String, String>> ips) { this.ips = ips; } public String getClusterName() { return clusterName; } public void setClusterName(String clusterName) { this.clusterName = clusterName; } public String getTimepath() { return timepath; } public void setTimepath(String timepath) { this.timepath = timepath; } public String getXpackSecurityUser() { return xpackSecurityUser; } public void setXpackSecurityUser(String xpackSecurityUser) { this.xpackSecurityUser = xpackSecurityUser; } public String getXpackSslKey() { return xpackSslKey; } public void setXpackSslKey(String xpackSslKey) { this.xpackSslKey = xpackSslKey; } public String getXpackSslCertificate() { return xpackSslCertificate; } public void setXpackSslCertificate(String xpackSslCertificate) { this.xpackSslCertificate = xpackSslCertificate; } public String getXpackSslCertificateauthorities() { return xpackSslCertificateauthorities; } public void setXpackSslCertificateauthorities(String xpackSslCertificateauthorities) { this.xpackSslCertificateauthorities = xpackSslCertificateauthorities; } public String getXpackSslVerificationmode() { return xpackSslVerificationmode; } public void setXpackSslVerificationmode(String xpackSslVerificationmode
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。