(记录)关于spring cloud 如何通过 nacos 中的 NamingService 获取服务

427 阅读1分钟

使用@NacosInjected注解时,namingService为null

可以使用下面代码获取服务:

@Autowired
private NacosServiceManager nacosServiceManager;

@Autowired
private NacosDiscoveryProperties nacosDiscoveryProperties;
NamingService namingService =  nacosServiceManager.getNamingService(nacosDiscoveryProperties.getNacosProperties());