一、错误日志
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'jmxMBeanExporter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/jmx/
JmxEndpointAutoConfiguration.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.boot.actuate.endpoint.jmx.JmxEndpointExporter]:
Factory method 'jmxMBeanExporter' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'serviceRegistryEndpoint' defined in class path resource [org/springframework/cloud/client/
serviceregistry/ServiceRegistryAutoConfiguration$ServiceRegistryEndpointConfiguration.class]:
Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException:
Failed to introspect Class [org.springframework.cloud.client.serviceregistry.endpoint.ServiceRegistryEndpoint]
from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
二、解决办法
2.1.修改pom文件
增加这个依赖引入:
<!-- SpringBoot Web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2.2.增加pom文件无效
这个报错其实就是没有找到要加载的类,一般在启动的时候报错。
加载不到的类有两种情况,一种是直接找不到要加载的依赖包,或者添加了依赖包后没有加载进入,需要看看是不是 maven 的设置问题,重新刷新加载一下 maven 的依赖,或者清一下 idea 的缓存;另外一种是导入了依赖包,但是依赖包中又引入了其他的依赖包中的类,这个类找不到。