Я хочу использовать https://github.com/opensearch-project/s ... opensearch в своем приложении на основе весенней загрузки.
Я пытался следовать инструкции по импорту и настройке клиента, но безуспешно:
Ниже мой код:
pom.xml
org.opensearch.client
spring-data-opensearch-starter
${spring-data-opensearch-starter.version}
org.opensearch.client
opensearch-rest-high-level-client
org.opensearch.client
opensearch-java
${opensearch-java.version}
OpenSearchCustomClientConfig.java
import org.opensearch.client.RestHighLevelClient;
import org.opensearch.data.client.orhlc.AbstractOpenSearchConfiguration;
import org.opensearch.data.client.orhlc.ClientConfiguration;
import org.opensearch.data.client.orhlc.RestClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OpenSearchCustomClientConfig extends AbstractOpenSearchConfiguration {
@Override
@Bean
public RestHighLevelClient opensearchClient() {
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("localhost:32526")
.build();
return RestClients.create(clientConfiguration).rest();
}
}
MyApp.java
@SpringBootApplication(exclude = {ElasticsearchDataAutoConfiguration.class})
@ConfigurationPropertiesScan
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class);
}
}
MyService.java
@Autowired
RestHighLevelClient restHighLevelClient;
...
final var queryBuilder = QueryBuilders.matchQuery("content", "120");
final var searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.size(1000);
searchSourceBuilder.query(queryBuilder);
var sr = new SearchRequest();
sr.indices("pdf-search");
sr.source(searchSourceBuilder);
var response = restHighLevelClient.search(sr, RequestOptions.DEFAULT);
1 попытка:
OpenSearchCustomClientConfig.java не компилируется из-за ошибки «Невозможно разрешить RestHighLevelClient»2 попытка:
Удалить
org.opensearch.client
opensearch-rest-high-level-client
из pom.xml
ошибка:
"The bean 'opensearchClient', defined in class path resource [org/opensearch/spring/boot/autoconfigure/OpenSearchClientConfigurations$OpenSearchClientConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [myapp/configuration/OpenSearchCustomClientConfig.class] and overriding is disabled."
3 попытки:
Добавить
main:
allow-bean-definition-overriding: true
в application.yml
ошибка: «Параметр 4 конструктора в MyService требует bean-компонента типа 'org. opensearch.client.RestHighLevelClient', который не удалось найти."
4 попытка:
Код удален из 3, попробуйте использовать это вместо этого:
spring:
main
autoconfigure:
exclude: org.opensearch.spring.boot.autoconfigure.OpenSearchClientAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration
ошибка:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchOperations' defined in class path resource [OpenSearchCustomClientConfig.class]: Post-processing of merged bean definition failed
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:577) ~[spring-beans-6.1.5.jar:6.1.5]
...
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.opensearch.data.client.orhlc.OpenSearchRestTemplate] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@4e0e2f2a]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:483) ~[spring-core-6.1.5.jar:6.1.5]
У меня нет идей, что нужно сделать, чтобы это настроить...
Использование
spring-boot 3.2.4
Подробнее здесь: https://stackoverflow.com/questions/786 ... ch-starter
Как использовать Spring-data-opensearch-starter ⇐ JAVA
Программисты JAVA общаются здесь
-
Anonymous
1719321416
Anonymous
Я хочу использовать https://github.com/opensearch-project/spring-data-opensearch в своем приложении на основе весенней загрузки.
Я пытался следовать инструкции по импорту и настройке клиента, но безуспешно:
Ниже мой код:
[b]pom.xml[/b]
org.opensearch.client
spring-data-opensearch-starter
${spring-data-opensearch-starter.version}
org.opensearch.client
opensearch-rest-high-level-client
org.opensearch.client
opensearch-java
${opensearch-java.version}
[b]OpenSearchCustomClientConfig.java[/b]
import org.opensearch.client.RestHighLevelClient;
import org.opensearch.data.client.orhlc.AbstractOpenSearchConfiguration;
import org.opensearch.data.client.orhlc.ClientConfiguration;
import org.opensearch.data.client.orhlc.RestClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OpenSearchCustomClientConfig extends AbstractOpenSearchConfiguration {
@Override
@Bean
public RestHighLevelClient opensearchClient() {
final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("localhost:32526")
.build();
return RestClients.create(clientConfiguration).rest();
}
}
[b]MyApp.java[/b]
@SpringBootApplication(exclude = {ElasticsearchDataAutoConfiguration.class})
@ConfigurationPropertiesScan
public class MyApp {
public static void main(String[] args) {
SpringApplication.run(MyApp.class);
}
}
[b]MyService.java[/b]
@Autowired
RestHighLevelClient restHighLevelClient;
...
final var queryBuilder = QueryBuilders.matchQuery("content", "120");
final var searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.size(1000);
searchSourceBuilder.query(queryBuilder);
var sr = new SearchRequest();
sr.indices("pdf-search");
sr.source(searchSourceBuilder);
var response = restHighLevelClient.search(sr, RequestOptions.DEFAULT);
1 попытка:
[b]OpenSearchCustomClientConfig.java[/b] не компилируется из-за ошибки «Невозможно разрешить RestHighLevelClient»2 попытка:
Удалить
org.opensearch.client
opensearch-rest-high-level-client
из pom.xml
ошибка:
"The bean 'opensearchClient', defined in class path resource [org/opensearch/spring/boot/autoconfigure/OpenSearchClientConfigurations$OpenSearchClientConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [myapp/configuration/OpenSearchCustomClientConfig.class] and overriding is disabled."
3 попытки:
Добавить
main:
allow-bean-definition-overriding: true
в [b]application.yml[/b]
ошибка: «Параметр 4 конструктора в MyService требует bean-компонента типа 'org. opensearch.client.RestHighLevelClient', который не удалось найти."
4 попытка:
Код удален из 3, попробуйте использовать это вместо этого:
spring:
main
autoconfigure:
exclude: org.opensearch.spring.boot.autoconfigure.OpenSearchClientAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration, org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration
ошибка:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'elasticsearchOperations' defined in class path resource [OpenSearchCustomClientConfig.class]: Post-processing of merged bean definition failed
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:577) ~[spring-beans-6.1.5.jar:6.1.5]
...
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.opensearch.data.client.orhlc.OpenSearchRestTemplate] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@4e0e2f2a]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:483) ~[spring-core-6.1.5.jar:6.1.5]
У меня нет идей, что нужно сделать, чтобы это настроить...
Использование
spring-boot 3.2.4
Подробнее здесь: [url]https://stackoverflow.com/questions/78667415/how-to-use-spring-data-opensearch-starter[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия