跳到主要内容

搭建微服务工程

资料

学习内容来自 B 站及网上的各种资料~

如下:

版本选择

Springboot 和 SpringCloud 版本选择:

版本对应关系:https://spring.io/projects/spring-cloud#overview

版本组件明细:https://start.spring.io/actuator/info    需要用JSON格式化工具查看

后面的演示代码版本选择:

  • SpringCloud Hoxton.SR12
  • SpringBoot 2.3.12.RELEASE
  • SpringCloud Alibaba 2.1.0.RELEASE
  • JDK8
  • Maven 3.5↑
  • Mysql 5.7
  • IDEA 2022.1
  • Centos7

构建项目

采用 Maven 聚合工程,父 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>

<groupId>cn.lichenghao.springcloud</groupId>
<artifactId>lichcloud</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>


<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<junit.version>4.1.2</junit.version>
<log4j.version>1.2.17</log4j.version>
<lombok.version>1.18.12</lombok.version>
<mysql.version>5.1.47</mysql.version>
<druid.version>1.1.23</druid.version>
<mybatis.spring.boot.version>2.1.3</mybatis.spring.boot.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.3.12.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR12</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis.spring.boot.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

</project>