前言
停留在jdk1.8的时间是不是有点多呢,所以脑海里总有一种这颗常青树不知道什么时候会倒的想法。不管它倒与不倒,前进就不会有错。
一、sofa是什么?
自行了解 sofa。
代码地址: https://gitee.com/sofastack/sofa-boot
二、环境准备
- JDK17
- sofaboot-dependencies 4.1.0
- nacos2.0.3
三、开撸
1.pom配置
<parent>
<groupId>com.alipay.sofa</groupId>
<artifactId>sofaboot-dependencies</artifactId>
<version>4.1.0</version>
<relativePath/>
</parent>
<dependencies>
.................................
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>rpc-sofa-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>tracer-sofa-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>runtime-sofa-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.alipay.sofa</groupId>
<artifactId>actuator-sofa-boot-starter</artifactId>
</dependency>
.................................
</dependencies>
2.yml配置
com:
alipay:
sofa:
rpc:
registry:
address: nacos://127.0.0.1:8848
3.启动类
@SpringBootApplication
public class Application {
public static void main(String[] args) {
StartupSpringApplication startupSpringApplication = new StartupSpringApplication(Application.class);
startupSpringApplication.run(args);
}
}
四、实际搭建遇到的问题
1.版本不匹配出现的问题
Client not connected,current status:STARTING
server is DOWNnow, detailed error message: Optional[The raft peer is in error: ERROR_TYPE_SNAPSHOT]
com.alipay.sofa.runtime.api.ServiceRuntimeException: RPC-010010009: 订阅元数据失败
Caused by: com.alipay.sofa.rpc.core.exception.SofaRpcRuntimeException: RPC-010060009: 订阅 provider 到 [NacosRegistry] 失败!
注:原项目使用的nacos是1.x,升级到nacos2.0.3就可以搞定了。
2.启动成功,但是服务没有注册成功
SOFA-BOOT-01-21001: HealthIndicator[mailHealthContributor] readiness check fail; the status is: DOWN; the detail is: {"location":"smtp.163.com:465","error":"jakarta.mail.MessagingException: Got bad greeting from SMTP host: smtp.163.com, port: 465, response: [EOF]"}
注:配置出错导致的问题,修改yml文件配置,要正确呦!要不就痛快点,把这段删了就完了
spring:
mail:
host: smtp.163.com
password: xxxx
username: xxxx@163.com
port: 465
总结
做升级工作也不太难,只要版本对应上,并注意新版本配置的变更,都没啥大问题。