搭建微服务项目

微服务项目搭建

image
微服务共有五个模块 加上父工程共六个

查看spring cloud alibaba 支持的spring boot 版本和spring cloud 版本

避免依赖错误
https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E
模块中需要添加三个依赖 分别是 spring-boot-parent spring-boot-web spring-cloud-dependencies 需要注意的是 spring-cloud-dependencies需要添加pom配置

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <packaging>pom</packaging>
    <modules>
        <module>order</module>
        <module>product</module>
    </modules>

    <parent>
        <artifactId>spring-boot-starter-parent</artifactId>
        <groupId>org.springframework.boot</groupId>
        <version>2.4.2</version>
    </parent>

    <groupId>com.lyra</groupId>
    <artifactId>shop-parent</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>2020.0.3</version>
            <type>pom</type>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

</project>

在然后就是创建自模块和spring boot 项目基本相同

posted @ 2021-09-25 12:05  RainbowMagic  阅读(173)  评论(0)    收藏  举报