创建Git仓库

项目基本信息从Git中拉取,首先在gitee或者github中创建仓库,命名为learning-online

初始化Git到本地

使用IDEA创建项目,选择Get from VCS,填写仓库的URL

创建.gitignore文件,填入如下内容:

logs/
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store

使用IDEA创建分支dev01,并切换到该分支

项目工程结构

提供服务的模块learning-online-contet的依赖继承关系如下,其他所有提供服务的模块都将按照如下关系创建

创建父工程

右键learning-online选择New下面的Module;填入learning-online-parent,注意其真实目录地址在learning-online目录下。

父工程只负责Maven版本控制,只保留pom.xml文件,内容如下:

pom.xml
<?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.swx</groupId>
<artifactId>learning-online-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>learning-online-parent</name>
<description>learning-online-parent</description>

<properties>
<java.version>11</java.version>
<spring.cloud.version>Hoxton.SR10</spring.cloud.version>
<spring.boot.version>2.3.9.RELEASE</spring.boot.version>
<mybatis-plus.version>3.4.1</mybatis-plus.version>
<lombok.version>1.18.18</lombok.version>
<mysql.connector.version>8.0.23</mysql.connector.version>
<knife4j.version>3.0.3</knife4j.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
<!-- knife4j接口文档 -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
<version>${knife4j.version}</version>
</dependency>

</dependencies>
</dependencyManagement>

<build>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

创建基础模块

创建新模块learning-online-base,其Parentlearning-online-parent但其目录位置在learning-online下,创建完成后其pom.xml的内容如下:

pom.xml
<?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>
<parent>
<groupId>com.swx</groupId>
<artifactId>learning-online-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../learning-online-parent</relativePath>
</parent>
<artifactId>learning-online-base</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>learning-online-base</name>
<description>learning-online-base</description>
<properties>
<java.version>11</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>

  • relativePath:指示其父工程的目录

创建内容管理模块

创建新模块**learning-online-content**,其Parentlearning-online-parent但其目录位置在learning-online下,目录结构如下:

learning-online
├── learning-online-base
├── learning-online-content
└── learning-online-parent

创建内容管理接口工程

创建步骤同上,创创建新模块learning-online-content-api,其Parentlearning-online-content

创建内容管理服务工程

创建步骤同上,创创建新模块learning-online-content-service,其Parentlearning-online-content

创建内容管理模块工程

创建步骤同上,创创建新模块learning-online-content-model,其Parentlearning-online-content

最终的目录结构

工程都是空的,只是初始化项目结构

learning-online
├── learning-online-base
├── learning-online-content
│ ├── learning-online-content-api
│ ├── learning-online-content-service
│ └── learning-online-content-model
└── learning-online-parent