环境:
JDK:17.0.5
SpringBoot:2.7.2
SpringCloud:2021.0.5
1、如何选择nacos版本,去官网查,springboot版本有对应的nacos版本,如果没有对应好,就会出来一系列的破问题,例如:依赖包时候不成功、项目无法启动、无法注册到注册中心等等,springcloud集成nacos
2、选好依赖版本后,网关遇到一个问题,配置文件中 cloud.gateway.routes … 和 cloud.gateway.discovery 配置冲突,
解决办法,增加以下配置:
spring:
cloud:
gateway:
predicate:
weight:
enabled: false
3、服务间通过feign调用时候,找不到服务,报错503
参考
解决方法:
pom依赖中:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
配置文件中:
spring:
profiles:
active: dev
application:
name: gateway #服务名
cloud:
loadbalancer:
ribbon:
enabled: false
4、因为本人项目中用到了国密加密,打包后的jar包启动报错
解决方案:
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- <configuration>-->
<!-- <includeSystemScope>true</includeSystemScope>-->
<!-- </configuration>-->
<configuration>
<requiresUnpack>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15to18</artifactId>
</dependency>
</requiresUnpack>
</configuration>
</plugin>
</plugins>
</build>