ElasticSearchConfig

1. 添加配置

<dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId></dependency>

2. es 配置信息


import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;@Configuration
public class ElasticSearchConfig {@Value("${spring.elasticsearch.rest.uris}")private String addr;@Value("${spring.elasticsearch.rest.username}")private String username;@Value("${spring.elasticsearch.rest.password}")private String password;@Bean(destroyMethod = "close")public RestHighLevelClient restHighLevelClient() {String[] segments = addr.split(",");HttpHost[] esNodes = new HttpHost[segments.length];for (int i = 0; i < segments.length; i++) {String[] hostAndPort = segments[i].split(":");esNodes[i] = new HttpHost(hostAndPort[0], Integer.parseInt(hostAndPort[1]), "http");}CredentialsProvider credentialsProvider = new BasicCredentialsProvider();credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));RestClientBuilder builder = RestClient.builder(esNodes);builder.setHttpClientConfigCallback(f -> f.setDefaultCredentialsProvider(credentialsProvider));return new RestHighLevelClient(builder);}
}

3. 異常信息

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticSearchConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.elasticsearch.rest.uris' in value "${spring.elasticsearch.rest.uris}"at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1425) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:755) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:402) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1247) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1236) [spring-boot-2.3.12.RELEASE.jar:2.3.12.RELEASE]at ManagementCenterApplication.main(ManagementCenterApplication.java:21) [-1.0.jar:na]
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.elasticsearch.rest.uris' in value "${spring.elasticsearch.rest.uris}"at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180) ~[spring-core-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126) ~[spring-core-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:239) ~[spring-core-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) ~[spring-core-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:918) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1248) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.15.RELEASE.jar:5.2.15.RELEASE]... 18 common frames omitted

這個就是因為 es 沒有配置用戶名密碼,而在程序當中寫了用戶密碼導致的問題

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/42601.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/42601.shtml
英文地址,請注明出處:http://en.pswp.cn/news/42601.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

k8s簡介、虛擬機快速搭建k8s集群、集群管理方式及K8S工作原理和組件介紹

文章目錄 1、k8s簡介1.1、部署方式的變遷1.2、定義1.3、Kubernetes提供的功能 2、虛擬機快速搭建k8s集群2.1、虛擬機配置&#xff08;centos7 2G內存2個處理器&#xff09;2.2、基礎環境準備2.3、docker安裝&#xff08;易踩坑&#xff09;2.4、安裝k8s組件2.5、master節點部署…

在linux系統中修改mysql數據目錄

目錄 1.查看mysql默認存儲路徑2.停止mysql服務3.移動或復制原數據目錄4.修改配置文件5.修改啟動文件6.配置AppArmor訪問控制規則7.重啟apparmor服務8.啟動mysql 1.查看mysql默認存儲路徑 在/etc/mysql/mysql.conf.d/mysqld.cnf中的datadir配置項。 datadir /var/lib/mysql2…

提高批量爬蟲工作效率

大家好&#xff01;作為一名專業的爬蟲程序員&#xff0c;我今天要和大家分享一些關于提高批量爬蟲工作效率的實用技巧。無論你是要批量采集圖片、文本還是視頻數據&#xff0c;這些經驗都能幫助你在大規模數據采集中事半功倍。廢話不多說&#xff0c;讓我們開始吧&#xff01;…

SUMO 創建帶有停車位的充電站 在停車位上充電

前言 SUMO提供的Charging Station是沒有停車位的&#xff0c;車輛只有在通過充電站區域或者停在充電站區域內時才能被充電&#xff0c;這時充電的車輛就會占用道路。然而&#xff0c;真實世界中的情況通常是充電站設在路邊&#xff0c;且提供一定量的車位用于停車&#xff0c;…

半導體自動化專用靜電消除器主要由哪些部分組成

半導體自動化專用靜電消除器是一種用于消除半導體生產過程中的靜電問題的設備。由于半導體制造過程中對靜電的敏感性&#xff0c;靜電可能會對半導體器件的質量和可靠性產生很大的影響&#xff0c;甚至造成元件損壞。因此&#xff0c;半導體生產中采用專用的靜電消除器是非常重…

setfacl給jenkins用戶加權限

用setfacl給jenkins用戶加一個/tmp的權限 setfacl是set File ACL&#xff08;訪問控制列表&#xff09;的縮寫 如果你想遞歸地將它應用到所有子目錄&#xff1a;添加-R標志&#xff0c;如下所示&#xff1a; yum -y install aclsetfacl -R -m u:jenkins:rwx /tmp Give speci…

Linux Day09

目錄 一、進程替換 二、Linux信號的使用 2.1 kill() 發送信號 2.2 signal() 改變進程對信號的響應方式 2.3 處理僵死進程 2.3.1 在信號處理函數中調用wait 2.3.2 Linux特有的 2.3.3 結果 一、進程替換 linux上創造一個新進程&#xff0c;沒有create創建方法&#xf…

數據分析15——office中的Excel基礎技術匯總

0、前言&#xff1a; 這部分總結就是總結每個基礎技術的定義&#xff0c;在了解基礎技術名稱和定義后&#xff0c;方便對相關技術進行檢索學習。筆記不會詳細到所有操作都說明&#xff0c;但會把基礎操作的名稱及作用說明&#xff0c;可自行檢索。本文對于大部分讀者有以下作用…

優化視頻流:利用美顏SDK提升直播質量的方法

隨著互聯網的迅猛發展&#xff0c;視頻直播已成為人們分享、交流和娛樂的重要方式。然而&#xff0c;在實際的直播過程中&#xff0c;視頻畫質可能受到諸多因素的影響&#xff0c;例如攝像頭品質、網絡狀況等。為了提升觀眾的體驗和吸引更多的觀眾&#xff0c;美顏技術逐漸成為…

Java Map、JSONObject、實體類互轉

文章目錄 前言Map、JSONObject、實體類互轉 前言 使用庫 com.alibaba.fastjson2&#xff0c;可完成大部分JSON轉換操作。 詳情參考文章: Java FASTJSON2 一個性能極致并且簡單易用的JSON庫 Map、JSONObject、實體類互轉 import com.alibaba.fastjson2.JSON; import com.alib…

Git分享-規范/建議/技巧

1. Git多人協作開發流程圖 1.1 processOn默認的模板 1.2 改造之后 https://www.processon.com/view/link/64ccaf56a433c931b2f9428a 訪問密碼&#xff1a;512I ① 總流程圖 ② feat分支&#xff08;功能/需求 分支&#xff09;流程 ③ bugfix分支&#xff08;緊急補丁分支&…

Qt平滑彈出頁面

目標功能&#xff1a; (1)按下btn&#xff0c;彈出綠色頁面。 (2)按下btn2,綠色頁面隱藏。 (3)按下左邊余下的區域&#xff0c;綠色頁面也隱藏。 (4)平滑地顯示和隱藏 效果&#xff1a; form.h #ifndef FORM_H #define FORM_H#include <QWidget>namespace Ui { class…

上半年營收19億,金融壹賬通第二增長曲線“加速上坡”

8月16日&#xff0c;壹賬通金融科技有限公司&#xff08;下稱“金融壹賬通”&#xff09;發布了截至2023年6月30日中期業績報告。 根據財報&#xff0c;2023年上半年&#xff0c;金融壹賬通實現營收18.99億元&#xff0c;毛利潤為6.96億元&#xff1b;歸母凈利潤率從-26.1%提升…

卷積神經網絡全解!CNN結構、訓練與優化全維度介紹!

目錄 一、引言1.1 背景和重要性1.2 卷積神經網絡概述 二、卷積神經網絡層介紹2.1 卷積操作卷積核與特征映射卷積核大小多通道卷積 步長與填充步長填充 空洞卷積&#xff08;Dilated Convolution&#xff09;分組卷積&#xff08;Grouped Convolution&#xff09; 2.2 激活函數R…

相機的位姿在地固坐標系ECEF和ENU坐標系的轉換

在地球科學和導航領域&#xff0c;通常使用地心地固坐標系&#xff08;ECEF&#xff0c;Earth-Centered, Earth-Fixed&#xff09;和東北天坐標系&#xff08;ENU&#xff0c;East-North-Up&#xff09;來描述地球上的位置和姿態。如下圖所示&#xff1a; ?地心地固坐標ecef和…

Linux內核的兩種安全策略:基于inode的安全與基于文件路徑的安全

實現系統安全的策略 在Linux中&#xff0c;一切且為文件&#xff0c;實現系統安全的策略主要可分為兩種&#xff1a;基于inode的安全、基于文件路徑的安全。 基于inode的安全 為文件引入安全屬性&#xff0c;安全屬性不屬于文件內容&#xff0c;它是文件的元數據&#xff0c…

EV PV AC SPI CPI TCPI

SPI EV / PV CPI EV / ACCPI 1.25 SPI 0.8 PV 10 000 BAC 100 000EV PV * SPI 10 000 * 0.8 8000 AC EV / CPI 8000 / 1.25 6400TCPI (BAC - EV) / (BAC -AC) (100 000 - 8 000) / (100 000 - 6 400) 92 000 / 93 600 0.98290598

RabbitMQ面試題

1. 什么是MQ MQ 就是消息隊列。是軟件和軟件進行通信的中間件產品 2. MQ的優點 異步處理 - 相比于傳統的串行、并行方式&#xff0c;提高了系統吞吐量。 應用解耦 - 系統間通過消息通信&#xff0c;不用關心其他系統的處理。 流量削鋒 - 可以通過消息隊列長度控制請求量…

Selenium webdriver_manager根據瀏覽器版本自動下載對應驅動程序

前言 webdriver_manager是什么&#xff1f; webdriver_manager 是 Python 中的一個庫&#xff0c;用于管理 Web 驅動程序。它的作用是自動下載和設置不同瀏覽器&#xff08;如 Chrome、Firefox、Edge 等&#xff09;的 Web 驅動程序&#xff0c;以便在自動化測試中使用這些瀏…

每日一題:leetcode1338 3n塊披薩

給你一個披薩&#xff0c;它由 3n 塊不同大小的部分組成&#xff0c;現在你和你的朋友們需要按照如下規則來分披薩&#xff1a; 你挑選 任意 一塊披薩。Alice 將會挑選你所選擇的披薩逆時針方向的下一塊披薩。Bob 將會挑選你所選擇的披薩順時針方向的下一塊披薩。重復上述過程…