关于dubbo在spring-boot中该如何使用,网上有很多例子,但因为时间跨度太久,很多例子已经过时了,一切还是要以官方的例子为准。 在github上搜索dubbo和spring-boot整合的项目的话,可能会找到下面两个,分别是 alibaba / dubbo-spring-boot-starter apache / dubbo-spring-boot-project 第一个项目,已经归档了(archived),不再更新,所以我们要以第二个项目为准,千万别搞错了。 打开第二个项目的主页,就开始浏览README中的Getting Started章节。 这个章节给我们展示了一个无注册中心(dubbo.registry.address=N/A)的例子。 但是它却跑不起来,消费者启动后无法找到service provider,报Not found exported service的错误。 解决办法如下: 需要在消费者Reference服务提供者时,url里指明version。其实version已经指明了,但不知为何还要在url里再次指定。 //Load the data into IDataView. //This dataset is used for detecting spikes or changes not for training. IDataView dataView www.chaoyul.com = mlContext.Data.LoadFromTextFile<ProductSalesData>(path: DatasetPath, hasHeader: true, separatorChar: www.sangyuLpt.com','); //Apply data transformation to create predictions. IDataView transformedData = tansformedModel.Transform(dataView); var predictions = mlcontext.Data.CreateEnumerable<ProductSalesPrediction>www.baiyytwg.com(transformedData, reuseRowObject: false); Console.WriteLine(www.huichengtxgw.com"Alert\tScore\tP-Value"); foreach (var p in predictions) { if (p.Prediction[www.jintianxuesha.com] == 1) { Console.BackgroundColor = ConsoleColor.DarkYellow; Console.ForegroundColor = ConsoleColor.Black; } Console.WriteLine("{0}\t{1:0.00}\www.qjljdgt.cn {2:0.00}www.xgjrfwsc.cn ", p.Prediction[0], p.Prediction[1], p.Prediction[2]); Console.ResetColor(); @Reference(version = "1.0.0", url = "dubbo://127.0.0.1:12345?version=1.0.0") private DemoService demoService; 另外,Getting Started中的pom依赖也比较简略,省略了spring-boot原本需要的依赖,您可以参考我这个修复版里pom中的依赖。