Maven继承依赖模块的依赖

编程入门 行业动态 更新时间:2024-10-21 17:36:22
本文介绍了Maven继承依赖模块的依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当前我有一个项目,其中模块B依赖于模块A.

Currently I have a project where module B depends on module A.

模块A为:

<project xmlns="maven.apache/POM/4.0.0" xmlns:xsi="www.w3/2001/XMLSchema-instance" xsi:schemaLocation="maven.apache/POM/4.0.0 maven.apache/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.A</groupId> <artifactId>P</artifactId> <version>1.0.0</version> </parent> <artifactId>A</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <name>A</name> <build> <sourceDirectory>${sourceDirectory}/A/src</sourceDirectory> </build> <dependencies> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> <version>5.0.0</version> <optional>true</optional> </dependency> </dependencies> </project>

模块B为:

<project xmlns="maven.apache/POM/4.0.0" xmlns:xsi="www.w3/2001/XMLSchema-instance" xsi:schemaLocation="maven.apache/POM/4.0.0 maven.apache/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.A</groupId> <artifactId>P</artifactId> <version>1.0.0</version> </parent> <artifactId>B</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <name>B</name> <build> <sourceDirectory>${sourceDirectory}/B/src</sourceDirectory> </build> <dependencies> <dependency> <groupId>com.A</groupId> <artifactId>C</artifactId> <version>1.0.0</version> <optional>true</optional> </dependency> <dependency> <groupId>com.A</groupId> <artifactId>A</artifactId> <version>1.0.0</version> </dependency> </dependencies> </project>

为了编译B,我需要a-dep中的类.如果我手动将a-dep作为依赖项添加,则一切都可以正常编译.但是该项目需要我依靠A来获取a-dep,而不是显式声明a-dep.

In order to compile B I need the classes in a-dep. If I manually add a-dep as a dependency everything compiles fine. But the project needs me to depend on A to get to a-dep instead of explicitly declare a-dep.

是否有一种方法可以根据模块A从a-dep获取类?

Is there a way to get the classes from a-dep by depending on module A?

推荐答案

能够通过删除true标签来解决此问题,因为它阻止了B能够看到依赖关系.

was able to solve it by removing the true tag as it prevents B to be able to see the dependency.

更多推荐

Maven继承依赖模块的依赖

本文发布于:2023-11-17 02:16:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608441.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模块   Maven

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!