在yml中添加配置
zuul:
user-service:
path: /springcloud-provider-dept/**
url: http://127.0.0.1:8001
后发现是springboot和springcloud版本太高的原因 建项目的时候因为版本太高所以不是导入的父项目版本的zuul 是我自己手动引入的
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<version>2.2.7.RELEASE</version>
</dependency>
但是springboot 在2.4版本之后就不支持zuul 改用Gateway 如果还要用zuul的话 把springboot 和springcloud的版本降低就好了
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR10</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.3.10.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
我将版本改为这样之后就不需要指定服务器物理地址了