问题描述:
ConfigurableApplicationContext applicationContext =
SpringApplication.run(ClusterMonitorApplication.class, args);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
try {
SpringApplication.exit(applicationContext);
} catch (Exception e) {
LOG.error("Shutdown failed", e);
}
如上所示:在项目使用SpringApplication.exit()退出服务时,出现下列的空指针异常:
java.lang.NullPointerException: null
at com.alibaba.cloud.nacos.NacosServiceManager.nacosServiceShutDown(NacosServiceManager.java:115)
at com.alibaba.cloud.nacos.registry.NacosServiceRegistry.close(NacosServiceRegistry.java:116)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.i