当前位置: 代码迷 >> 综合 >> Failed to introspect Class [org...DiscoveryClientOptionalArgsConfiguration from ClassLoader ...
  详细解决方案

Failed to introspect Class [org...DiscoveryClientOptionalArgsConfiguration from ClassLoader ...

热度:25   发布时间:2024-02-07 22:54:38.0

在启动zuul工程时候报的问题

报错原文:


java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:481) ~[spring-core-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:358) ~[spring-core-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:414) ~[spring-core-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.lambda$getTypeForFactoryMethod$2(AbstractAutowireCapableBeanFactory.java:743) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1688) ~[na:1.8.0_251]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:742) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:681) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:649) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1608) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:524) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:495) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:617) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:609) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1243) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]at org.springframework.boot.SpringApplication.getExitCodeFromMappedException(SpringApplication.java:880) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]at org.springframework.boot.SpringApplication.getExitCodeFromException(SpringApplication.java:868) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]at org.springframework.boot.SpringApplication.handleExitCode(SpringApplication.java:855) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:806) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]at com.yss.ZuulServerApplication.main(ZuulServerApplication.java:14) [classes/:na]
Caused by: java.lang.NoClassDefFoundError: com/netflix/discovery/AbstractDiscoveryClientOptionalArgsat java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_251]at java.lang.ClassLoader.defineClass(ClassLoader.java:756) ~[na:1.8.0_251]at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_251]at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) ~[na:1.8.0_251]at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[na:1.8.0_251]at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[na:1.8.0_251]at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[na:1.8.0_251]at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_251]at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[na:1.8.0_251]at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_251]at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_251]at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_251]at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_251]at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_251]at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_251]at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.2.7.RELEASE.jar:5.2.7.RELEASE]... 21 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.netflix.discovery.AbstractDiscoveryClientOptionalArgsat java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_251]at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_251]at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_251]at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_251]... 37 common frames omittedProcess finished with exit code 1

解决方案:
工程pom.xml中找到:

		 <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-netflix-eureka-client</artifactId></dependency>

这个依赖,改成下面的依赖:

		<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency>

启动成功:
在这里插入图片描述

  相关解决方案