idea maven 项目融合

背景

:项目A 和项目B 是两个独立的多模块项目,项目A 和项目B ,均为独立的数据源 。其中项目B 有两个数据原。 需要将项目B 以多模块的方式融合进项目A。
解决版本。建立项目C,只含有pom的,空项目,项目A和项目B做为多模块引入。其中项目B的启动类某块排除掉,只包含项目B的业务快块模块。

融合前后项目结构

融合前A 项目

在这里插入图片描述

融合前B 项目结构

在这里插入图片描述

融合后的项目C结构
在这里插入图片描述

步骤

1. 在gitLab 创建C项目代码仓库,并下载到本地(或者在本地创建项目空项maven目后在同步gitLab也可以)

2. 将项目A、B文件夹复制至项目C

3. 导入项目A、B的项目modul

4. 修改项目的modul 父子关系

C项目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 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.1.3.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><modelVersion>4.0.0</modelVersion><groupId>C</groupId><artifactId>xxx-C</artifactId><version>1.0</version><packaging>pom</packaging><properties><vvv.version>cfcustom-2.0.3-SNAPSHOT</platform6.version><!--平台版本--><spring-boot.version>2.1.3.RELEASE</spring-boot.version><!--springboot版本--><java-source.version>8</java-source.version><!--jdk版本--><java-target.version>8</java-target.version><!--jdk版本--></properties><modules><module>A</module><module>B</module></modules><repositories><repository><id>xxx</id><name>xxx</name><url>http:/xxx/xxx/xxx/mvn-group/</url></repository></repositories>
</project>

A 项目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><parent><groupId>C</groupId><artifactId>C</artifactId><version>1.0</version><relativePath/></parent><groupId>xxxx</groupId><artifactId>A</artifactId><version>0.0.1-SNAPSHOT</version><packaging>pom</packaging><description>组件父工程</description><name>XXX-A</name><url>https://maven.aliyun.com/mvn/search</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><java.version>1.8</java.version>………………<prod.version>6.4.2</prod.version></properties><modules><module>A-api</module><module>A-pub</module><module>A-service</module><module>A-boot</module></modules><dependencyManagement>…………………………</dependencies></dependencyManagement><!-- Maven私服 --><repositories><repository><id>avic-public</id><name>avic-public</name><url>http://xxxx:9999/rxxxx/</url></repository></repositories>
</project>

配置说明
指定工程C的相对路径 默认为 …/pom.xml
A.service 工程配置说明

<?xml version="1.0"?>
<projectxsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><modelVersion>4.0.0</modelVersion><parent><groupId>xxx</groupId><artifactId>A</artifactId><version>0.0.1-SNAPSHOT</version><relativePath/></parent><artifactId>A-service</artifactId><description>组件的后台服务项目,提供组件的后台服务,包括rest、service、dao和mapper</description><name>xxxxx-A-service</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>xxxx.platform6</groupId><artifactId>A-pub</artifactId><version>${component.version}</version></dependency></dependencies><build><resources><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes></resource></resources></build>
</project>

标签表示要将A-Service 模块下的资源文件也要打进包

A-pom.xml 配置

<?xml version="1.0"?>
<projectxsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><modelVersion>4.0.0</modelVersion><parent><groupId>xxx</groupId><artifactId>A</artifactId><version>0.0.1-SNAPSHOT</version><relativePath/></parent><artifactId>A-boot</artifactId><description>组件的后台服务启动工程</description><name>A-boot</name><url>http://maven.apache.org</url><profiles><!-- 开发环境配置 --><profile><id>dev</id><properties><profiles.active>dev</profiles.active></properties><!-- 默认激活该配置 --><activation><activeByDefault>true</activeByDefault></activation><build><resources><!-- 复制logback-spring.xml--><resource><directory>src/main/resources</directory><filtering>false</filtering><includes><include>logback-spring.xml</include></includes></resource></resources></build></profile></profiles><dependencies><dependency><groupId>xxxx</groupId><artifactId>A-service</artifactId><version>${component.version}</version><exclusions><exclusion><artifactId>spring-plugin-core</artifactId><groupId>org.springframework.plugin</groupId></exclusion></exclusions></dependency><dependency><groupId>xxxx</groupId><artifactId>B-order-service</artifactId><version>${component.version}</version><exclusions><exclusion><artifactId>spring-plugin-core</artifactId><groupId>org.springframework.plugin</groupId></exclusion></exclusions></dependency>……</dependencies><build><finalName>${project.artifactId}</finalName><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>A.Application</mainClass></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin><plugin><artifactId>maven-resources-plugin</artifactId><configuration><encoding>utf-8</encoding><useDefaultDelimiters>true</useDefaultDelimiters><nonFilteredFileExtensions><nonFilteredFileExtension>lrc</nonFilteredFileExtension><nonFilteredFileExtension>res</nonFilteredFileExtension></nonFilteredFileExtensions></configuration></plugin></plugins><resources><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes></resource><resource><directory>src/main/resources</directory><includes><include>application-${profiles.active}.yml</include><include>application-common.yml</include></includes><filtering>false</filtering></resource><resource><directory>src/main/resources</directory><excludes><exclude>logback-spring.xml</exclude><exclude>bootstrap.yml</exclude><exclude>application*.yml</exclude><exclude>prod/*</exclude></excludes><filtering>false</filtering></resource><resource><directory>src/main/resources</directory><includes><include>application.yml</include></includes><filtering>true</filtering></resource></resources></build>
</project>
  1. A-boot作为项目的启动类,需要把B的业务代码需要导入进来,需要进入
xxxx B-order-service ${component.version} spring-plugin-core org.springframework.plugin 2.引入需要打进包的资源文件

3.需要指定打包的启动类入口
pring-boot-maven-plugin,一半只需要在打包的启动类中包含,不需要在别的modul模块包含

<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass>A.Application</mainClass></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin><plugin><artifactId>maven-resources-plugin</artifactId><configuration><encoding>utf-8</encoding><useDefaultDelimiters>true</useDefaultDelimiters><nonFilteredFileExtensions><nonFilteredFileExtension>lrc</nonFilteredFileExtension><nonFilteredFileExtension>res</nonFilteredFileExtension></nonFilteredFileExtensions></configuration></plugin>

打包有可能会包
SpringBoot 打包异常:Unable to find main class

问题原因:因为 pom 集成了 boot-parent,打包时,在没有指定 mainClass 入口时,会找所有子模块下的 main 方法,除去 web 目录下有之外,其他模块下面均没有,导致打包异常。

1、指定对应模块的 main 入口即可。
在这里插入图片描述

参考
https://blog.csdn.net/azhegps/article/details/98246273

B模块的pom结构同样配置如上,只不过B模块不需要引入B-boot

relativePath 的用法

relativePath:
1)指定查找该父项目pom.xml的(相对)路径。默认顺序:relativePath > 本地仓库 > 远程仓库
2)没有relativePath标签等同…/pom.xml, 即默认从当前pom文件的上一级目录找
3)表示不从relativePath找, 直接从本地仓库找,找不到再从远程仓库找

关于2)经过测试,似乎 没有relativePath标签时,它没有从当前pom文件的上一级目录找,子模块继承不到父模块中dependencyManagement中包的version信息。

因此,强烈推荐,子模块配置relativePath元素,指定 …/pom.xml。

pom.xml中resouces标签

参考 :https://blog.csdn.net/qq_43501821/article/details/135588894

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/755391.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

RPM与DNF的操作实践

这几课有三个目标&#xff1a; 第一步&#xff1a;先配置软件源 跳转到yum.repos.d目录&#xff0c;用vim创建一个openeuler_x84_64.repo文件。这个文件就是我们将会用到的软件源。 我们在里面添加这些东西&#xff0c;保存并退出即可。 然后&#xff0c;我们用yum list all就…

深入理解nginx的请求限速模块[下]

目录 3. 源码分析3.1 配置指令3.1.1 limit_req_zone指令3.1.2 limit_req指令3.1.3 limit_req_dry_run指令3.1.4 limit_req_log_level指令3.1.5 limit_req_status指令3.2 模块初始化3.3 请求处理3.3.1 ngx_http_limit_req_handler3.3.1 ngx_http_limit_req_lookup3.3.2 ngx_http…

阿里云发布 AI 编程助手 “通义灵码”——VSCode更强了 !!

文章目录 什么是 通义灵码&#xff08;TONGYI Lingma&#xff09; 快速体验“通义灵码” 什么是“通义灵码”&#xff08;TONGYI Lingma&#xff09; 通义灵码&#xff08;TONGYI Lingma&#xff09;&#xff0c;是阿里云出品的一款基于通义大模型的智能编码辅助工具&#xff…

C语言字符函数和字符串函数以及内存函数(全是代码版):一篇文章让你秒懂基础!

JAMES别扣了-CSDN博客&#xff08;个人主页&#xff09; &#x1f495;在校大学生一枚。对IT有着极其浓厚的兴趣 ✨系列专栏目前为C语言初阶、后续会更新c语言的学习方法以及c题目分享. &#x1f60d;希望我的文章对大家有着不一样的帮助&#xff0c;欢迎大家关注我&#xff0c…

【Java常用API】正则表达式练习

&#x1f36c; 博主介绍&#x1f468;‍&#x1f393; 博主介绍&#xff1a;大家好&#xff0c;我是 hacker-routing &#xff0c;很高兴认识大家~ ✨主攻领域&#xff1a;【渗透领域】【应急响应】 【Java】 【VulnHub靶场复现】【面试分析】 &#x1f389;点赞➕评论➕收藏 …

【TypeScript系列】混入

混入 Table of contents 介绍 混入示例 理解示例 介绍 ↥ 回到顶端 除了传统的面向对象继承方式&#xff0c;还流行一种通过可重用组件创建类的方式&#xff0c;就是联合另一个简单类的代码。 你可能在Scala等语言里对mixins及其特性已经很熟悉了&#xff0c;但它在Java…

Excel新函数TEXTJOIN太强大了,这些高级用法太实用了

今天跟大家分享WPS中新函数TEXTJOIN的使用方法和技巧&#xff0c;它不仅仅是一个强大的文本连接函数&#xff0c;还有一些高级用法可以帮助我们快速解决日常难题。 TEXTJOIN函数介绍 作用&#xff1a;TEXTJOIN函数是文本连接函数&#xff0c;使用分隔符连接列表或文本字符串区…

【C++】手撕AVL树

> 作者简介&#xff1a;დ旧言~&#xff0c;目前大二&#xff0c;现在学习Java&#xff0c;c&#xff0c;c&#xff0c;Python等 > 座右铭&#xff1a;松树千年终是朽&#xff0c;槿花一日自为荣。 > 目标&#xff1a;能直接手撕AVL树。 > 毒鸡汤&#xff1a;放弃自…

数媒大厦会议中心 成都数字产业园示范基地

数媒大厦会议中心&#xff0c;位于成都市金牛区国际数字影像产业园3楼区域&#xff0c;这里也是成都数字产业园示范基地的核心区域。该成都文创产业园及辐射周边配套公园用地约500亩&#xff0c;涵盖产业实训空间、产业实验室、数字资产交易平台、产业集群发展空间、双创孵化空…

工业智能网关的功能特点、应用及其对企业产生的价值-天拓四方

一、工业智能网关的功能特点 工业智能网关是一种具备数据采集、传输、处理能力的智能设备&#xff0c;它能够将工业现场的各种传感器、执行器、控制器等设备连接起来&#xff0c;实现设备间的信息互通与协同工作。同时&#xff0c;工业智能网关还具备强大的数据处理能力&#…

PR是啥?一篇文章学会Pull Request到底是干嘛的

PR&#xff1f;Pull Request 概念 PR,全称Pull Request&#xff08;拉取请求&#xff09;&#xff0c;是一种非常重要的协作机制&#xff0c;它是 Git 和 GitHub 等代码托管平台中常见的功能。在开源项目中&#xff0c;Pull Request 被广泛用于参与社区贡献&#xff0c;从而促…

html--蝴蝶

<!DOCTYPE html> <html lang"en" > <head> <meta charset"UTF-8"> <title>蝴蝶飞舞</title> <link rel"stylesheet" href"https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.cs…

富格林:安全出金关注可信操作

富格林悉知&#xff0c;现货黄金投资凭借着诸多优势&#xff0c;成为了热门的投资产品之一&#xff0c;也获得了投资者的追捧。在投资中想要安全盈利出金&#xff0c;投资者一定要沉下心来学习专业知识和技术&#xff0c;这样才能在以后的投资操作中避免亏损&#xff0c;顺畅盈…

Android 13.0 kenel和frameworks中修改ram运行内存的功能实现

1.前言 在13.0的系统rom产品开发定制中,在对一些产品开发中的配置需求方面,在产品后续订单中,产品提出要提高硬件配置,但是硬件方面已经定板,项目时间比较仓促,所以 来不及对硬件重新定制,就需要软件方面在ram运行内存的容量大小方面作假,修改ram真实的大小容量,所以…

YOLOV5 改进:增加注意力机制模块(SE)

1、前言 本章将介绍yolov5的改进项目,为v5增加新的模块---注意力机制、SE模块 大部分更改的代码是重复的,只有少部分需要更改,下面会详细讲解 yolov5的yaml文件介绍:YOLOV5 模型:利用tensorboard查看网络结构和yaml文件介绍-CSDN博客 yolov5的模块更改,C3更改为C2f模块…

19 # 高级类型:索引类型

let obj {a: 1,b: 2,c: 3 } // 抽取值形成数组 function getValues(obj: any, keys: string[]) {return keys.map(k > obj[k]) }console.log(getValues(obj, [a, b])); // [1, 2] console.log(getValues(obj, [e, f])); // [undefined, undefined] 属性不存在也不报错可以使…

pgsql中按照逗号拆分成列

原始数据如下&#xff0c;要拆分dict_label字段&#xff1a; selectt_d.dict_sort,t_d.dict_label,t_d.dict_value from sys_dict_data t_d where t_d.dict_type qc_audit_type ORDER BY t_d.dict_sort 关键代码&#xff1a; split_part(t_d.dict_label,,,1) as mValue, sp…

递推算法C++

所谓递推&#xff0c;是指从已知的初始条件出发&#xff0c;依据某种递推关系&#xff0c;逐次推出所要求的各中间结果及最后结果。其中初始条件或是问题本身已经给定&#xff0c;或是通过对问题的分析与化简后确定。从已知条件出发逐步推到问题结果&#xff0c;此种方法叫顺推…

4.GetMapping和PostMapping 和 @RequestMapping的区别。RequestBody 和ResponseBody的区别

1.GetMapping和PostMapping 和 RequestMapping的区别 //GetMapping只能通过get请求。 public class Hello1{GetMapping("hello1")public String h1(){return "1";}//PostMapping只能通过post请求&#xff0c;需要输入参数。 public class Hello2{PostMapp…

C++作业day6

编程1&#xff1a; 封装一个动物的基类&#xff0c;类中有私有成员&#xff1a;姓名&#xff0c;颜色&#xff0c;指针成员年纪 再封装一个狗这样类&#xff0c;共有继承于动物类&#xff0c;自己拓展的私有成员有&#xff1a;指针成员&#xff1a;腿的个数&#xff08;整型 …