SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

作者:一个蒟蒻的博客 时间:2022-10-28 02:38:30 

SpringCloud是分布式微服务架构的一站式解决方案,十多种微服务架构落地技术的集合体,俗称微服务全家桶

SpringCloud和SpringBoot版本选择

自2019年以后官方建议使用2.0以后的版本
官网地址
在官网的页首可以看到最新版本以及对应的springboot版本

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解
SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

在官网可以看到官方推荐的springcloud与springboot相对应的版本

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

更详细的版本选择

版本info

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

其中可以看到官方推荐的版本选择
目前选择以下版本

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

相关技术选型

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

创建工程

铁则:约定>配置>编码

创建父工程

New Project

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

新建maven工程

字符编码
在setting中设置

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

使注解生效

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

选择java编译版本为java8

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

配置父工程的pom文件

指定打包方式为pom

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

删除自带的src文件夹

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

更换pom.xml文件中的部分内容


<!-- 统一管理jar包版本 -->
 <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
<lombok.version>1.16.18</lombok.version>
<mysql.version>5.1.47</mysql.version>
<druid.version>1.1.16</druid.version>
<mybatis.spring.boot.version>1.3.0</mybatis.spring.boot.version>
 </properties>

<!--  使用dependencyManagement,父工程指定,子工程不用再指定-->
 <dependencyManagement>
 <dependencies>
 <dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
 </dependency>
 <!--spring boot 2.2.2-->
 <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
 </dependency>
 <!--spring cloud Hoxton.SR1-->
 <dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR1</version>
<type>pom</type>
<scope>import</scope>
 </dependency>
 <!--spring cloud 阿里巴巴-->
 <dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.1.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
 </dependency>
 <!--mysql-->
 <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
<scope>runtime</scope>
 </dependency>
 <!-- druid-->
 <dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid.version}</version>
 </dependency>

<!--mybatis-->
<dependency>
 <groupId>org.mybatis.spring.boot</groupId>
 <artifactId>mybatis-spring-boot-starter</artifactId>
 <version>${mybatis.spring.boot.version}</version>
</dependency>
<!--junit-->
<dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <version>${junit.version}</version>
</dependency>
<!--log4j-->
<dependency>
 <groupId>log4j</groupId>
 <artifactId>log4j</artifactId>
 <version>${log4j.version}</version>
</dependency>
 </dependencies>

</dependencyManagement>

<build>
<plugins>
 <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
 <fork>true</fork>
 <addResources>true</addResources>
</configuration>
 </plugin>
</plugins>
 </build>

更换部分如下

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

为了防止打包时因为test出错而卡住,需要skip maven生命周期中的test

SpringCloud学习笔记之SpringCloud搭建父工程的过程图解

dependencyManagement 和dependencies的区别

  • dependencyManagement 通常在父工程中声明,用于声明依赖的version和scope,而不会实际引入包

  • dependencies通常在子工程中声明,会实际引入包,如果引入了父工程声明过的包,则声明时不再需要指定版本

来源:https://www.cnblogs.com/poifa/p/15361673.html

标签:SpringCloud,父工程
0
投稿

猜你喜欢

  • c# RSA非对称加解密及XML&PEM格式互换方案

    2022-07-10 12:19:31
  • Springboot集成graylog及配置过程解析

    2023-06-18 17:15:02
  • 总结C#网络编程中对于Cookie的设定要点

    2021-12-28 20:16:43
  • Java InheritableThreadLocal使用示例详解

    2023-04-17 20:18:12
  • SpringBoot+JPA 分页查询指定列并返回指定实体方式

    2021-08-26 11:54:57
  • C#微信公众号开发之自定义菜单

    2023-01-23 02:07:08
  • Java设计模式之静态代理模式实例分析

    2021-05-30 17:44:19
  • 浅析java修饰符访问权限(动力节点Java学院整理)

    2023-07-13 18:07:34
  • RocketMQ broker 消息投递流程处理PULL_MESSAGE请求解析

    2021-11-18 17:12:49
  • WinForm实现自定义右下角提示效果的方法

    2023-01-19 08:19:57
  • springboot自定义异常视图过程解析

    2023-06-29 09:44:36
  • java反射应用详细介绍

    2022-06-14 04:59:45
  • Android studio 自动换行和取消自动换行操作

    2023-08-09 12:16:16
  • 详解Java 自动装箱与拆箱的实现原理

    2022-08-16 11:35:51
  • Java HashMap底层实现原理

    2023-10-31 19:55:34
  • Android实现沉浸式导航栏实例代码

    2023-02-18 02:15:17
  • C#仿Windows XP自带的扫雷游戏

    2023-07-30 07:40:48
  • c语言实现基数排序解析及代码示例

    2021-10-17 19:37:51
  • JAVA中使用FTPClient实现文件上传下载实例代码

    2021-08-17 20:45:05
  • java实现电话本系统

    2021-06-05 20:39:39
  • asp之家 软件编程 m.aspxhome.com