我有以下 Maven 项目结构:
parent_project
+--main_application
+--domain_models_and_repository
+--module_1
+--module_2
+--module_3
以及以下简化的 POMS:
父项目.pom
<project>
<dependencies>
[Spring Boot dependencies]
</dependencies>
<modules>
<module>main_application</module>
<module>domain_models_and_repository</module>
<module>module_1</module>
<module>module_2</module>
<module>module_3</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
主应用程序
<project>
<parent>
<artifactId>parent_project</artifactId>
</parent>
<dependencies>
<dependency>
<artifactId>domain_models_and_repository</artifactId>
</dependency>
<dependency>
<artifactId>module_1</artifactId>
</dependency>
<dependency>
<artifactId>module_2</artifactId>
</dependency>
<dependency>
<artifactId>module_3</artifactId>
</dependency>
</dependencies>
</project>
module_1
<project>
<parent>
<artifactId>parent_project</artifactId>
</parent>
<dependencies>
<dependency>
<artifactId>domain_models_and_repository</artifactId>
</dependency>
</dependencies>
</project>
module_2
<project>
<parent>
<artifactId>parent_project</artifactId>
</parent>
<dependencies>
<dependency>
<artifactId>domain_models_and_repository</artifactId>
</dependency>
</dependencies>
</project>
module_3
<project>
<parent>
<artifactId>parent_project</artifactId>
</parent>
<dependencies>
<dependency>
<artifactId>domain_models_and_repository</artifactId>
</dependency>
<dependency>
<artifactId>module_1</artifactId>
</dependency>
<dependency>
<artifactId>module_2</artifactId>
</dependency>
</dependencies>
</project>
事实上,我有更多的模块,其中更多是其他模块的依赖项。当我跑步时mvn install
我得到了一个 1.2GB 的主应用程序文件。我注意到所有模块的所有依赖项都已组装
到模块中。因此,许多 jar 文件被多次组装到该文件中。我怎样才能避免这种情况?