微服务网关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