IDEA一个项目多JAR包文件夹
1.父工程的 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"> <modelVersion>4.0.0</modelVersion> <!-- 父工程坐标 --> <groupId>org.example</groupId> <artifactId>parent-project</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <!-- 父工程必须是 pom 打包类型 --> <!-- 声明所有子模块 --> <modules> <module>dlla</module> <!-- 子模块目录名 --> <module>mainexe</module> <!-- 子模块目录名 --> </modules> </project>
2.子模块 dlla 的 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.example</groupId> <artifactId>parent-project</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> <!-- 父 POM 路径 --> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>dlla</artifactId> <!-- 子模块坐标,groupId/version 继承父工程 --> </project>
如果自带了groupId,要注释掉,会自动继承父类:
<!-- <groupId>org.example</groupId>-->
3.子模块 mainexe 的 pom.xml(依赖 dlla)

<?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.example</groupId> <artifactId>parent-project</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>mainexe</artifactId> <!-- 依赖 dlla 模块 --> <dependencies> <dependency> <groupId>org.example</groupId> <artifactId>dlla</artifactId> <version>1.0-SNAPSHOT</version> <scope>compile</scope> </dependency> </dependencies> </project>
4.一键打包所有模块

即可以打包根工程,也可以打包启动工程 mainexe 。

浙公网安备 33010602011771号