本文介绍了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继承依赖模块的依赖
发布评论