Spring 升级问题 - ClassNotFoundException
Spring upgrade issue - ClassNotFoundException
我已将 spring 启动从 2.2.6.RELEASE 升级到 2.7.0。
升级后,我在启动应用程序时收到 ClassNotFoundException。
我试过 2.6.6 但结果是一样的。
我的 pom 文件看起来像
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
</dependency>
异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactiveElasticsearchClient' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@3b192d32]
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.0.jar:2.7.0]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@3b192d32]
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.3.20.jar:5.3.20]
... 15 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/xcontent/XContentParser
.....
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467) ~[spring-core-5.3.20.jar:5.3.20]
... 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.xcontent.XContentParser
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
... 26 common frames omitted
有人可以帮忙吗?
我终于解决了这个问题。在父 pom 中明确给出了弹性搜索版本。一旦我删除给定的版本错误就消失了,应用程序工作正常。
我已将 spring 启动从 2.2.6.RELEASE 升级到 2.7.0。 升级后,我在启动应用程序时收到 ClassNotFoundException。 我试过 2.6.6 但结果是一样的。
我的 pom 文件看起来像
<dependency>
<groupId>io.projectreactor.netty</groupId>
<artifactId>reactor-netty</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
</dependency>
异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reactiveElasticsearchClient' defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ReactiveElasticsearchRestClientAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@3b192d32]
org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.0.jar:2.7.0]
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.data.elasticsearch.client.reactive.DefaultReactiveElasticsearchClient] from ClassLoader [jdk.internal.loader.ClassLoaders$AppClassLoader@3b192d32]
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.3.20.jar:5.3.20]
... 15 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/elasticsearch/xcontent/XContentParser
.....
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:467) ~[spring-core-5.3.20.jar:5.3.20]
... 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.elasticsearch.xcontent.XContentParser
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
... 26 common frames omitted
有人可以帮忙吗?
我终于解决了这个问题。在父 pom 中明确给出了弹性搜索版本。一旦我删除给定的版本错误就消失了,应用程序工作正常。