Gateway 父项目依赖

为了在学习 Spring Cloud Gateway 过程中快速搭建 demo 环境,我们将通过 Maven 的父项目管理项目中使用到的 Spring Boot、Spring Cloud 和 Spring Cloud Alibaba 的版本信息,项目结构如下图:

Gateway 父项目依赖

该项目主要提供订单服务(service-order)和用户服务(service-user),然后验证 Gateway 中的各种功能。

注意:该项目将采用 Nacos 作为服务注册中心和配置中心,关于如何使用 Nacos,请参考 “Spring Cloud Alibaba Nacos 教程”。

Maven 依赖

下面是父项目的依赖信息:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.hxstrive.springcloud</groupId>
   <artifactId>springcloud_learn</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <name>springcloud_learn</name>
   <packaging>pom</packaging>

   <modules>
       <!-- 订单服务 -->
       <module>service_order</module>
       <!-- 用户服务 -->
       <module>service_user</module>
       <!-- gateway 网关 -->
       <module>gateway_demo01</module>
   </modules>

   <properties>
       <java.version>8</java.version>
   </properties>

   <dependencyManagement>
       <dependencies>
           <!-- spring cloud alibaba 依赖 -->
           <dependency>
               <groupId>com.alibaba.cloud</groupId>
               <artifactId>spring-cloud-alibaba-dependencies</artifactId>
               <version>2.1.2.RELEASE</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>

           <!-- spring cloud 依赖 -->
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-cloud-dependencies</artifactId>
               <version>Greenwich.RELEASE</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>

           <!-- spring boot 依赖 -->
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-dependencies</artifactId>
               <version>2.1.3.RELEASE</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>

           <!-- MyBatis 依赖 -->
           <dependency>
               <groupId>org.mybatis.spring.boot</groupId>
               <artifactId>mybatis-spring-boot-starter</artifactId>
               <version>2.0.0</version>
           </dependency>

           <!-- MySQL 数据库驱动依赖 -->
           <dependency>
               <groupId>com.mysql</groupId>
               <artifactId>mysql-connector-java</artifactId>
               <version>5.1.27</version>
           </dependency>
       </dependencies>
   </dependencyManagement>

   <build>
       <plugins>
           <plugin>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-maven-plugin</artifactId>
           </plugin>
       </plugins>
   </build>

</project>

我们使用的版本信息如下:

  • Spring Cloud Alibaba 2.1.2.RELEASE

  • Spring Cloud Greenwich.RELEASE

  • Spring Boot 2.1.3.RELEASE

注意,在后续 demo 项目的 pom.xml 中,我们将使用如下信息去引用父项目的依赖等信息:

<parent>
   <groupId>com.hxstrive.springcloud</groupId>
    <artifactId>springcloud_learn</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
说说我的看法
全部评论(
没有评论
关于
本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,请来信告知:hxstrive@outlook.com
公众号