微服務網關2-搭建Gateway服務


一、創建父模塊infrastructure

1、創建模塊

在guli_parent下創建普通maven模塊
Artifact:infrastructure

2、刪除src目錄

二、創建模塊api_gateway

1、創建模塊

在infrastructure下創建普通maven模塊
Artifact:api_gateway

2、配置pom

在api_gateway的pom中添加如下依賴

<dependencies>
    <!-- 網關 -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>
    </dependency>
</dependencies>

3、配置application.yml

server:
  port: 9110 # 服務端口

spring:
  profiles:
    active: dev # 環境設置
  application:
    name: infrastructure-apigateway # 服務名

4、logback.xml

修改日志輸出的目錄名為 apigateway

 <property name="log.path" value="D:/project/helen/guli_log/apigateway" />

5、創建啟動類

package com.atguigu.guli.infrastructure.apigateway;

@SpringBootApplication
public class InfrastructureApiGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(InfrastructureApiGatewayApplication.class, args);
    }
}

6、啟動網關


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM