无人问津也好,技不如人也罢,你都要试着静下来,去做自己该做的事。
添加父管理项目
springboot 2.6.3 + spring-cloud 2021.0.1 + spring cloud alibaba 2021.1
在最顶层右击项目,点击 add as maven project
,做为整个项目的父项目,做依赖管理。
版本依赖说明:
https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E
Spring Cloud Alibaba Version | Spring Cloud Version | Spring Boot Version |
---|---|---|
2021.0.1.0* | Spring Cloud 2021.0.1 | 2.6.3 |
<?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>
<groupId>groupId</groupId>
<artifactId>gulimall</artifactId>
<version>1.0-SNAPSHOT</version>
<name>gulimall</name>
<description>项目父工程,依赖管理</description>
<packaging>pom</packaging>
<!-- 项目统一管理jar版本 -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<!-- 作用:锁定版本 + 子模块不用写groupId和version -->
<dependencyManagement>
<dependencies>
<!-- springboot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.6.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- spring-cloud -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- spring cloud alibaba -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2021.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.3</version>
<configuration>
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
<type>pom</type>
<scope>import</scope>
上面的做法其实就相当于实现了多继承,毕竟我们导入了SpringCloud
和SpringBoot
的两个父模块的jar包依赖。
初始化项目骨架
-
gulimall-xxx(product/order/ware/coupon/member)
-
并在每个子模块下引入
web
(前端)、openfegin
(模块间调用)、actuator
(项目监控)