简要总结一下Nacos项目搭建方法。
Nacos + Sentinel + Dubbo
个人笔记,大佬可直接忽略。
一、概念
1.Nacos:是阿⾥巴巴开源的⼀个针对微服务架构中服务发现、配置管理和服务管理平台。
二、Nacos+Sentinel+Dubbo项目搭建简述
三、其它内容与踩过的坑
1.从网上下载nacos注册中心1.2.1,下载地址:https://github.com/alibaba/Nacos
访问nacos管理界面:http://127.0.0.1:8848/nacos/#/login(默认端⼝8848,账号和密码 nacos/nacos)
2.nacos服务端安装:https://www.jianshu.com/p/84537b025873
3.nacos客户端入门:https://blog.csdn.net/cqlaopan/article/details/103991295
nacos配置中心:https://www.cnblogs.com/spiritmark/p/13009702.html
nacos中使用dubbo:https://blog.csdn.net/zhanglei500038/article/details/108279628
Sentinel使用方法:https://blog.csdn.net/qq_36185997/article/details/107152602
4.nacos md5不同,一直刷日志:换nacos新版服务器。
5.报错找不到dubbo服务:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'apiController': Injection of @Reference dependencies is failed; nested exception is java.lang.IllegalStateException: Failed to check the status of the service dubbo.SendMail. No provider available for the service dubbo.SendMail from the url spring-cloud://localhost:9090/org.apache.dubbo.registry.RegistryService?application=lagou-service-code&dubbo=2.0.2&interface=dubbo.SendMail&lazy=false&methods=sendMail&pid=20456&qos.enable=false®ister.ip=192.168.92.1&release=2.7.3&side=consumer&sticky=false×tamp=1616131999024 to the consumer 192.168.92.1 use dubbo version 2.7.3
@Service注解使用的不是dubbo的,改成dubbo的。
import org.apache.dubbo.config.annotation.Service;
6.下载sentinel.jar,启动sentinel
启动:java -jar sentinel-dashboard-1.7.1.jar
用户名/密码:sentinel/sentinel
java -jar sentinel-dashboard-1.8.1.jar
java -Dserver.port=7777 -jar sentinel-dashboard-1.8.1.jar
登录地址:http://localhost:8080/#/dashboard/home
用户名:sentinel
密码:sentinel
6.nacos中使用gateway:
https://blog.csdn.net/weixin_38470396/article/details/107020002
https://blog.csdn.net/m0_37862829/article/details/106548421
7.导入依赖后仍报错,找不到jar包
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
解决方法:增加version字段,指定版本号
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>