支持config多部署环境配置服务,支持dubbo rpc服务,支持nacos注册中心服务发现
附件带有完整可以验证的OK的rpc,config-server服务整合,
依赖版本冲突整合的干净有注释的springcloud项目包。
1、 启动,编译,打包报错
(或者单操作报错,如打包不报错,启动报错等)
1)缺少对应服务包,通过报错的找不到的类名,去查找对应的依赖包,引入到pom.xml文件中
2)清除缓存(clear 或者idea restart)(一般作用不大)
3)spring-boot-dependencies spring-cloud-dependencies spring-cloud-alibaba-dependencies 三者版本不匹配
--:重复配置,版本干扰,
--如多模块常见,子父模块依赖,子父模块分别都配置了对应的包依赖版本,且版本不统一,相互干扰,统一为父模块配置或者删除父模块的配置,保留一个配置。
--父模块中配置了spring-boot-dependencies 的版本和spring-boot-starter-parent的版本不一致,建议取消<parent></parent>的配置,把spring-boot-starter单独配置依赖,不依赖parent,避免版本干扰
2、config服务启动失败或者其他模块无法拿到对应配置信息
2.1、配置文件目录结构:
2.2、config server
--config server添加依赖spring-cloud-config-server,启动主类添加注解:
@EnableConfigServer
依赖:
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-config-server</artifactId> </dependency>
配置信息如下
server:
port: 8088
nacos:
server-addr: localhost:8848
spring:
application:
name: interview_config
cloud:
nacos:
discovery:
server-addr: ${nacos.server-addr}
config:
server:
native:
search-locations: classpath:/config/{profile}
profiles:
active: native
说明:
profiles.active对应的是上面spring.cloud.config中的配置类型
search-locations : 是根据自己的配置信息目录结构,从resources目录下开始的