在Maven中使用另一个子模块中的类 [英] use a class from the other child module in maven
问题描述
我有两个子模块A和Util.并且我在A likes的pom文件中添加了依赖项:
I have two child modules, A and Util. And I have added the dependency in the pom file of A likes:
<dependency>
<groupId>xxx</groupId>
<artifactId>Util</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
有了这个,我可以在模块A中使用Util的类.
With this, I can use the class of Util in module A.
但是当我要生成A的jar时,会出现
But when I want to generate the jar of A, there is an error of
在xxx
是模块Util的类的地方,
xxx
不会退出.
xxx
does not exit wherexxx
es the class of module Util.
我想知道如何生成.jar
I want to know how I can generate the .jar
更新:
错误信息是:
在添加依赖项之后,Maven依赖项中没有.jar,它是文件"Util":
And After I added the dependency, there is not the .jar in the Maven dependencies, it is a file "Util":
Util模块为:
我还在Util中使用了"Maven安装",结果是:
I also used "maven install" in Util and the result is:
我用来生成的命令是" mvn clean package -DskipTests = true
"
The command I used to generate is "mvn clean package -DskipTests=true
"
推荐答案
我已经解决了!
依赖关系应为:
<dependency>
<groupId>AWSTest</groupId>
<artifactId>AWSUtil</artifactId>
<version>0.0.1-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
这篇关于在Maven中使用另一个子模块中的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!