指定注册中心
server:
port: 8091
spring:
application:
name: zuul
eureka:
instance:
prefer-ip-address: true
hostname: localhost
client:
registerWithEureka: true
fetch-registry: true
serviceUrl:
//指定位置
defaultZone: http://192.168.0.113:8761/eureka/
需要的依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
main的注释
@SpringBootApplication
//启动
@EnableZuulProxy
//查找与发现
@EnableDiscoveryClient
public class Zuul {
public static void main(String[] args) {
SpringApplication.run(Zuul.class);
}
}