1.idea创建maven项目
通过idea创建maven项目,如果存在java或者resource文件夹为未加载时选择右边的控制面板,选择创建的网关项目reimport就行了
2.添加pom依赖
网关一般来说可以使用gateway或者是zuul,但现在推荐使用前者,不管是功能还是性能方面都要强与后者
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
新建application.yml文件
server:
port: 9001
spring:
application:
name: gateway-admin
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
3.小结
本文只是初略的创建网关项目,后面的博文才会详细的讲解如何搭建一个真正的网关服务,以及网关服务于各个微服务项目与web服务器之间的搭配。