如何修复NoClassDefFoundError,同时使用Http2SolrClient构建器与solr 9+?

wribegjk  于 2023-08-04  发布在  Solr
关注(0)|答案(1)|浏览(157)

我正在将maven用于我的项目和此依赖项:

<dependency>
  <groupId>org.apache.solr</groupId>
  <artifactId>solr-solrj</artifactId>
  <version>9.2.0</version>
</dependency>

字符串
Java版本:17
Spring Boot版本:2.7.13
代码中的用法:

@Bean
public SolrClient solrClient() {
  return new Http2SolrClient.Builder(host).build();
}


我有正确的主机与HttpSolrClient(弃用),但没有与Http2SolrClient
构建成功-应用程序运行时出错:

Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/http/HttpFields$Mutable
at org.apache.solr.client.solrj.impl.Http2SolrClient$Builder.<init> 
(Http2SolrClient.java:992)


我试着添加任何版本的org.eclipse.jetty-没有帮助。
在文档中-9.2.0版应支持Http 2SolrClient:https://solr.apache.org/docs/9_2_0/solrj/org/apache/solr/client/solrj/impl/Http2SolrClient.html
如何正确地创建一个可工作的Http 2SolrClient?

w3nuxt5m

w3nuxt5m1#

似乎我找到了答案,这个问题是几个月前在这里咨询的:
https://issues.apache.org/jira/browse/SOLR-16668?jql=text%20~%20%22Http2SolrClient%20HttpFields%22
所以"forcing all the jetty dependencies to a specific version"适用于这种情况:

dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation group: 'org.apache.solr', name: 'solr-solrj', version: '9+'
implementation group: 'org.eclipse.jetty.http2', name: 'http2-client', version: '10.0.13'
implementation group: 'org.eclipse.jetty.http2', name: 'http2-common', version: '10.0.13'
implementation group: 'org.eclipse.jetty.http2', name: 'http2-hpack', version: '10.0.13'
implementation group: 'org.eclipse.jetty.http2', name: 'http2-http-client-transport', version: '10.0.13'
implementation group: 'org.eclipse.jetty', name: 'jetty-util', version: '10.0.13'
implementation group: 'org.eclipse.jetty', name: 'jetty-io', version: '10.0.13'
implementation group: 'org.eclipse.jetty', name: 'jetty-http', version: '10.0.13'
implementation group: 'org.eclipse.jetty', name: 'jetty-client', version: '10.0.13'
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-client', version: '10.0.13'
implementation group: 'org.eclipse.jetty', name: 'jetty-alpn-java-client', version: '10.0.13'
}

字符串
" the problem I have with SolrJ 9.2.0 is caused somehow by Spring Boot, because they override the version of Jetty."

相关问题