Maven似乎了解 utilities-20190520.jar 并将其带入构建,但是,在编译使用代码的代码时, utility-20190520.jar 的软件包并且找不到符号。请注意,Maven还获得了许多其他第三方JAR(例如 org.apache.common-io ,NiFi JAR等),并且代码可以毫无错误地使用它们。
我有多个模块:
. pipeline (parent)
+-- shared
`-- other modules
父级(或超级级) pom.xml 指定此依赖项,以供所有子模块使用:
<dependency>
<groupId>com.acme</groupId>
<artifactId>utilities</artifactId>
<version>20190520</version>
</dependency>
执行mvn dependency:tree compile
(在父子目录中)
...
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ pipeline ---
[INFO] com.acme.nifi.pipeline:pipeline:pom:2.0.0
[INFO] +- com.acme:utilities:jar:20190520:compile (my JAR)
[INFO] +- org.apache.nifi:nifi-api:jar:1.9.2:compile (NiFi JAR)
...
-似乎已经从本地存储库中获取了 utilities.jar ,然后编译了第一个(子)模块:
[INFO] com.acme.nifi.pipeline:shared:jar:2.0.0
...
[INFO] +- com.acme:utilities:jar:20190520:compile (my JAR again)
...
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/russ/sandboxes/pipeline/shared/src/main/java/com/acme/DeferringXmlParsingFilter.java:[10,33] package com.acme.xml does not exist
...
[ERROR] /home/russ/sandboxes/pipeline/shared/src/main/java/com/acme/nifi/processor/DeferringXmlParsingFilter.java:[61,70] cannot find symbol
symbol: class Tag
location: class com.acme.nifi.processor.DeferringXmlParsingFilter
编译器抱怨它不知道包 com.acme.xml 或 com.acme.xml.Tag ,该包中的类,尽管所有出现的外观都包含它们的 utilities-20190520.jar 。
我正在像对待其他JAR一样对待 utilities-20190520.jar ,它位于〜/ .m2 / repository 中,我有一个<repository>
规范正确地设置了 settings.xml -实际上,还引入了许多其他JAR。这是本地存储库中的我的JAR:
~/.m2/repository
+-- com
+-- acme
+-- utilities
+-- 20190520
+-- utilities-20190520.jar
+-- utilities-20190520.pom
+-- etc.
有想法吗?