idea maven 项目融合

news2025/2/26 9:30:32

背景

:项目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"?>
<project
        xsi: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"?>
<project
        xsi: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.coloradmin.cn/o/1528718.html

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

相关文章

【经验分享】Wubuntu------体验Windows和Ubuntu的结合体

【经验分享】Wubuntu------体验Windows和Ubuntu的结合体 最近看到有一款Wubuntu的文章&#xff0c;对于习惯使用windows操作系统&#xff0c;又不熟悉ubuntu系统的程序员小白来说&#xff0c;可以说是福音了。目前的Wubuntu兼容性可能还有一点问题&#xff0c;如果再迭代几次的…

nodejs 使用express插件multer文件上传,接收不到文件的bug

把路径改成绝对路径即可 改成 temp是你想上传到文件夹的路径&#xff0c;一般是在项目根目录下

pinia的使用vue3

1.安装pinia pinia持久化工具pinia-plugin-persist npm install pinia pinia-plugin-persist -D -S2.使用pinia main.js import store from "//store"; app.use(store);index.js import { createPinia } from "pinia"; import piniaPluginPersist fro…

攻防世界新手模式例题(Web)

PHP2 首先我们查看页面&#xff0c;查看前端代码 发现均没有什么有效信息&#xff0c;由题目可知&#xff0c;此问题与php相关&#xff0c;于是我们可以看一下他的index.php文件 查看时用?index.phps 补充知识&#xff1a;phps文件就是php的源代码文件&#xff0c;通常用于…

【超图】白模数据如何与抽屉效果结合,展示白膜内部结构

作者&#xff1a;taco 最近在支持的过程中&#xff0c;客户在看别的项目中&#xff0c;发现白模是可以抽插的。而非单独一个白色模型建筑。那么如何使用SuperMap产品来实现抽插的效果呢&#xff1f;本篇文章结合SuperMap iDesktopX产品以及SuperMap iClient for Cesium产品进行…

工业级5g路由器使用案例(5g智慧安防解决方案)

​项目背景: 现代化智慧安防需要满足远程可视化监控、设备联网管理、数据加密传输等多重需求,对通信网络的带宽、时延、安全性等提出了很高要求。业内急需一款高可靠、高性能、易管理的通信网关设备,来确保安防系统的顺利运行。 安装部署: SR800-D路由器采用紧凑型全金属机箱…

【Linux进阶之路】HTTPS = HTTP + S

文章目录 一、概念铺垫1.Session ID2.明文与密文3.公钥与私钥4.HTTPS结构 二、加密方式1. 对称加密2.非对称加密3.CA证书 总结尾序 一、概念铺垫 1.Session ID Session ID&#xff0c;即会话ID&#xff0c;用于标识客户端与服务端的唯一特定会话的标识符。会话&#xff0c;即客…

后端系统开发之——接口参数校验

今天难得双更&#xff0c;大家点个关注捧个场 原文地址&#xff1a;后端系统开发之——接口参数校验 - Pleasure的博客 下面是正文内容&#xff1a; 前言 在上一篇文章中提到了接口的开发&#xff0c;虽然是完成了&#xff0c;但还是缺少一些细节——传入参数的校验。 即用户…

TCP - 传输控制协议

TCP - 传输控制协议 是一种面向连接的可靠传输协议。 特点&#xff1a; TCP是面向连接&#xff08;虚连接&#xff09;的传输层协议。 每一条TCP连接有且只能有两个端点。 可靠、有序、无丢弃和不重复。 TCP协议提供全双工通讯。 发送缓存 存放发送方TCP准备发送的数据。T…

一键截取万像:视频快照工具的终极指南

在这个视频时代,我们不可能手动截取每一个视频的特定帧作为缩略图或参考用途。这不仅费时费力,而且效率低下。但是,有了Python和强大的库,您可以创建一个自动化工具,在几秒钟内从视频文件中获取缩略图快照。 在本文中,我将分享一个Python脚本,它使用wxPython和OpenCV库,让您只…

基于有限状态机开发健壮的Nodejs/TCP客户端

有限状态机是一种数学计算模型&#xff0c;它描述了在任何给定时间只能处于一种状态的系统的行为。形式上&#xff0c;有限状态机有五个部分&#xff1a; 初始状态值 (initial state)有限的一组状态 (states)有限的一组事件 (events)由事件驱动的一组状态转移关系 (transition…

Foxmail邮箱空间不够或邮件数太多

Foxmail邮箱空间不够或邮件数太多 解决办法&#xff1a; ①远程管理&#xff0c;删除远程邮件 ②删除本地邮件并同步服务器 ①远程管理&#xff0c;删除远程邮件 ②删除本地邮件并同步服务器 打开设置》》高级 此外&#xff0c;为了方便管理邮件可以设置过滤器 欢迎各位大佬…

51单片机LED8*8点阵显示坤坤跳舞打篮球画面

我们作为一名合格的 ikun&#xff0c;专业的小黑子&#xff0c;这个重要的知识必须学会。 先看效果&#xff1a; 51LED点阵_鸡你太美 这里我们首先要用到延时函数Delay&#xff1a; void Delay(unsigned int xms) {unsigned char i, j;while(xms--){ i 2;j 239;do{while (-…

物联网和工业物联网的区别——青创智通

工业物联网解决方案-工业IOT-青创智通 物联网&#xff08;IoT&#xff09;和工业物联网&#xff08;IIoT&#xff09;作为现代科技的重要分支&#xff0c;正在逐渐渗透到我们的日常生活和工业生产中。它们的应用范围广泛&#xff0c;涵盖了从智能家居到自动化工厂的多个领域。…

CTF题型 Http2降级走私原理分析例题分享

CTF题型 Http2降级走私原理分析&例题分享 文章目录 CTF题型 Http2降级走私原理分析&例题分享HTTP/2请求走私的产生回顾一下Http请求走私原理Http2请求的消息划分实际生产环境的限制如何利用H2.CL 实验环境准备例题分析H2.CL请求走私[GeekChanllenge 2023 Ez_Smuggling]…

http协议的历史与基本概念

文章目录 历史和发展起源&#xff1a;HTTP/0.9&#xff08;1991年&#xff09;&#xff1a;HTTP/1.0&#xff08;1996年&#xff0c;RFC 1945&#xff09;&#xff1a;HTTP/1.1&#xff08;1997年&#xff0c;RFC 2068&#xff1b;1999年更新为RFC 2616&#xff09;&#xff1a…

【动态规划】【 数位dp】2827. 范围中美丽整数的数目

本文涉及知识点 数位dp 动态规划汇总 LeetCode2827. 范围中美丽整数的数目 给你正整数 low &#xff0c;high 和 k 。 如果一个数满足以下两个条件&#xff0c;那么它是 美丽的 &#xff1a; 偶数数位的数目与奇数数位的数目相同。 这个整数可以被 k 整除。 请你返回范围 [l…

写作之路:寻找动力与认可的探索

✍️作者简介&#xff1a;小北编程&#xff08;专注于HarmonyOS、Android、Java、Web、TCP/IP等技术方向&#xff09; &#x1f433;博客主页&#xff1a; 开源中国、稀土掘金、51cto博客、博客园、知乎、简书、慕课网、CSDN &#x1f514;如果文章对您些帮助请&#x1f449;关…

Android14音频进阶:AudioFlinger究竟如何混音?(六十三)

简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长! 优质专栏:Audio工程师进阶系列【原创干货持续更新中……】🚀 优质专栏:多媒体系统工程师系列【原创干货持续更新中……】🚀 人生格言: 人生从来没有捷径,只…

R语言中的常用基础绘图函数 直方图,箱线图,条形图,散点图

目录 R语言中的绘图参数 绘图函数 1.plot函数绘制散点图 2.hist函数绘制直方图 如何修饰直方图? 如何在直方图上标注各组频数&#xff1f; 使用text函数把某些信息标注在直方图上 如何在直方图上添加概率密度曲线&#xff1f; 3.boxplot函数绘制箱线图 4.barplot函数…