nacos报错java.lang.ClassNotFoundException: com.netflix.config.DynamicPropertyFactory解决方案
问题背景
使用LoadBalancerClient报错java.lang.ClassNotFoundException: com.netflix.config.DynamicPropertyFactory
java.lang.ClassNotFoundException: com.netflix.config.DynamicPropertyFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_221]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_221]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) ~[na:1.8.0_221]
解决方案
1 找不到类,说明没有引入这个依赖,然后看了一下nacos引入了,,但排除了很多依赖,这个核心被排除掉了,所以报错
<exclusion>
<artifactId>archaius-core</artifactId>
<groupId>com.netflix.archaius</groupId>
</exclusion>
2 正常引入的依赖,因为引入了其他很多东西,所以排除了,很多根据自己需要把排除删除掉
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
<version>2.2.0.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>HdrHistogram</artifactId>
<groupId>org.hdrhistogram</groupId>
</exclusion>
<exclusion>
<artifactId>spring-cloud-commons</artifactId>
<groupId>org.springframework.cloud</groupId>
</exclusion>
<exclusion>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
</exclusion>
<exclusion>
<artifactId>commons-lang3</artifactId>
<groupId>org.apache.commons</groupId>
</exclusion>
<exclusion>
<artifactId>httpclient</artifactId>
<groupId>org.apache.httpcomponents</groupId>
</exclusion>
<exclusion>
<artifactId>spring-cloud-starter</artifactId>
<groupId>org.springframework.cloud</groupId>
</exclusion>
</exclusions>
</dependency>
作为程序员第 145 篇文章,每次写一句歌词记录一下,看看人生有几首歌的时间,wahahaha …