步驟
- 啟動nacos服務(wù)
- 從項目中注釋掉spring-cloud-starter-eureka懈凹,或者netflix的eureka相關(guān)依賴 (如未完全注釋蜀变,出現(xiàn)下面異常)
- 引入nacos依賴
- 修改配置文件,啟動項目
未完全注釋eureka依賴
Field registration in org.springframework.cloud.client.serviceregistry.ServiceRegistryAutoConfiguration$ServiceRegistryEndpointConfiguration required a single bean, but 2 were found:
nacosRegistration: defined by method 'nacosRegistration' in class path resource [org/springframework/cloud/alibaba/nacos/NacosDiscoveryAutoConfiguration.class]
eurekaRegistration: defined in BeanDefinition defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]
原因在于eureka的maven依賴還在介评,如果使用idea工具库北,用maven helper插件打開項目maven依賴圖,搜索eureka找到項目在哪里依賴了eureka-client威沫,注釋掉即可贤惯。